I'm beginner for node.js and javascript. I'm looking for method how I call some api with url parameter in node.js. for example api url like that '[address]/api/id:/list/'
I want to set value at id: with 'request' method.
var request = require('request');
var option = {
method: 'GET',
uri: 'http://someaddress/api/id:/list/'
}
request( option , function(err, res, body) {
if( err != null ) {
console.error(err);
}
if(body != null) {
console.log(body);
}
});
Please Let me know, how I change my code.
var myId = "someid";
option.uri = option.uri.replace('/id:/', '/'+myId+'/');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.