I have my own rest API, that internally calls an NLP API, for which I have to post some data on their URL. I am using needle to achieve this, but there's some error that I cannot catch, and my own api is returning 500 to the frontend.
Here is that part of my server.js code:
app.post('/api/get',function(req,res) {
//console.log(req);
console.log("here in post ");
if(!req.body){
return res.send(400);
}
//console.log(req.body.msg);
var searchQuery = req.body.msg;
var options = { 'api-key' : '3080a0e0-1111-11e5-a409-7159d0ac8188' };
needle.post('http://api.cortical.io:80/rest/text/keywords?retina_name=en_associative',searchQuery,options,function(err, resp){
if(err){
console.log('something went wrong :' + err);
}
console.log('Got :'+resp );
});
I reach here in post
every time, but nothing after that. I am also curious that is this correct way to specify my api-key for the external API.
Thanks.