Hi, there is this following code which I'd like to bring the request part
out of "app.post", store it in a separate file and call it whenever needed.
I have tried the export method but I was keep getting the undefined for
"req" and "res".
app.post('/hook', function (req, res) {
url = "https://MY_URL",
// ( request part )
// I'd like to store following to a separate file
// and call it from main file whenever needed.
request({url : url, headers : {"Authorization" : auth}},
function (error, response, body) {
parseString(body, function (err, result) {
try {
return res.json({
"SOME_JSON": "JSON"
});
} catch (err) {
console.error("no request!", err);
}
});
});
// end request
});
a help on this would be greatly appreciated.
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/8802d48f-da79-44b6-af9c-5a95b492443e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.