我需要在节点服务器内进行http调用。可选参数为:
这意味着url(相对路径)应该如下所示:
/v1/clans?name=**exampleValue**
到目前为止,我的http请求选项如下:
app.get('/v1/:clans?=:name', (req, res) => {
console.log(req.path)
const options = {
host: 'api.clashofclans.com',
path: req.path,
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer *token*'
}
};
const x = https.get(options, (request) => {...});
但那不管用。有人知道如何在我的路径属性中包含可选参数吗?