Code:
var rp = require('request-promise');
var options = {
method: 'POST',
uri: 'http://c663fe13.ngrok.io/ap/lighton',
body: {"color": 'white'},
json: true // Automatically stringifies the body to JSON
};
rp(options)
.then(function (parsedBody) {
// POST succeeded...+
console.log("parsedBody", parsedBody);
})
.catch(function (err) {
// POST failed...
console.log("err", err);
});
but this gives me the following error:
{ RequestError: Error: getaddrinfo EAI_AGAIN c663fe13.ngrok.io:80 at new RequestError (/srv/node_modules/request-promise-core/lib/errors.js:14:15) at Request.plumbing.callback (/srv/node_modules/request-promise-core/lib/plumbing.js:87:29) at Request.RP$callback [as _callback] (/srv/node_modules/request-promise-core/lib/plumbing.js:46:31)
. . .
name: 'RequestError', message: 'Error: getaddrinfo EAI_AGAIN c663fe13.ngrok.io:80',
cause: { Error: getaddrinfo EAI_AGAIN c663fe13.ngrok.io:80 at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26) errno: 'EAI_AGAIN', code: 'EAI_AGAIN', syscall: 'getaddrinfo', hostname: 'c663fe13.ngrok.io', host: 'c663fe13.ngrok.io', port: 80 },
I trie to call that API with postman and it's working fine.