I'm working on a NodeJS/Express program and I'm trying to get a POST request to return data. When I return a direct string, I get the correct response.
app.post("/DoStuff", function(req, res, Data) {
DoStuf.DoStuffFunction(req.body.UserID, function(label) {
Data = label
})
res.send({message: "Stuff"});
})
When I change it to return a variable (which is still a string) it only returns "{}".
app.post("/DoStuff", function(req, res, Data) {
DoStuf.DoStuffFunction(req.body.UserID, function(label) {
Data = label
})
res.send({message: Data});
})
Even when I make Data = "foo" the response is "{}"