Question

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.

No correct solution

OTHER TIPS

var myId = "someid";

option.uri = option.uri.replace('/id:/', '/'+myId+'/');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top