我正在使用request promise插件request来创建get和post API。我想用一个参数传递URL。下面是我的代码。如何在URL中传递参数值?
async function getDetails (req) {
var options = {
url: 'http://localhost:3000/api/student/id/{studen_id}/branch/{studentbranch}',
method: 'GET',
headers: {
'User-Agent': 'my request',
'Authorization': 'Bearer {my token}',
'Content-Type': 'application/json',
'Accept': 'application/json'
},
json: true
};
let res= await rp(options)
.then(function (body) {
return body;
})
.catch(function (err) {
console.log("error get balance",err)
});
return res;
}
2条答案
按热度按时间wkyowqbh1#
nfzehxib2#
要通过URL传递参数,可以像这样传递: