Reputation: 1455
Actual api should be like below:
https://.../api/v1/users/getprofile?access_token={{access_token}}
Below is how I am trying to call the API using request
const request = require('request');
request.get("https://.../api/v1/users/getProfile?accessToken=",{accessToken: req.query.accessToken})
However, it failed. How can I print out whats the url being called ? And how can I fix the error ?
Upvotes: 1
Views: 51
Reputation: 5760
Try this:
const request = require('request');
try {
var strURI = encodeURI("https://.../api/v1/users/getProfile?accessToken=");
request.get(strURI, {accessToken: req.query.accessToken});
} catch(e) {
console.log("Exception: " + e.message);
}
Upvotes: 1
Reputation: 1370
You can use something like this.
const request = require("request")
request.get({url: "http://.../api/v1/users/getprofile", qs: {"accessToken": "xxxxx"}}, function(err, response, body) {
console.log(err, body);
})
Upvotes: 1