Skip to content

Instantly share code, notes, and snippets.

@rabbishuki
Last active February 26, 2019 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rabbishuki/489057f40579e89ba06af3702cd52e7b to your computer and use it in GitHub Desktop.
Save rabbishuki/489057f40579e89ba06af3702cd52e7b to your computer and use it in GitHub Desktop.
sendToOtherNodeService = (url, bodyReq, timeout, callback) => {
try {
request({
url: url,
method: 'POST',
json: true,
body: bodyReq,
timeout: timeOut,
}, (error, response, body) => {
if (error != null) {
cb({error: error || ''});
}
} else {
try {
body = JSON.parse(body);
} catch (e) {
}
if (body) {
cb({response: body});
} else {
cb({error: 'body empty'});
}
}
}).on('error', function (e) {
cb({error: e});
});
} catch (e1) {
cb({error: e1});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment