如何在nodejs中的端点调用中传递一个variables

我有一个variables,例如var merchanttoken = requestConfig.merchant_connect_token ,如何通过它时,呼叫端点例如

request.get('http://pi.call/v2/{merchanttoken}/info, function)

我需要在URL中传递variables。

我build议传递它作为POST请求,而不是GET。 由于身份validation令牌是敏感内容。

不过,如果你喜欢GET更改URL格式。

http://pi.call/v2/info?merchanttoken={merchanttoken}

你可以在服务器端nodejs通过

 var url = require('url'); var url_parts = url.parse(request.url, true); var merchanttoken = url_parts.merchanttoken;