I have this curl request that worked, and I hope to turn it into node.js code.
curl -H "Content-Type: application/json" -X POST -d '{"text":"ibm","date":{"from":"20170330","to":"20170530"},"restrictedDateRange":false}' https://finsights.mybluemix.net/api/query
However, I tried in my way but i am quite sure i did something wrong as the response body doesnt match what i got from the curl request.
My code that failed: server.get('/hello', function create(req, res, next) { // //sample request
request({
url: "https://finsights.mybluemix.net/api/query",
method: "POST",
headers: {
"content-type": "application/json",
data:
{
"text": "ibm",
"date":{"from":"20170330","to":"20170530"},
"restrictedDateRange": "false",
}
},
json: true, // <--Very important!!!
},
function(err, res, body) {
console.log(body);
});
// //end of sample request
console.log("success");
return next();
});
Please can anyone teach me how to transform it please?
via Carson Yau
No comments:
Post a Comment