I'm just starting to learn about HTTP post methods and would like to know if it is possible to get access to variables within the method so that I can export/use it.
Here is my code:
var word = [];
app.post("/search", (req, res) => {;
console.log(req.body)
word = req.body["searchedWord"]
});
console.log(word)
FYI: The req i get looks like { searchedWord: 'soda' }
It currently returns "undefined". If I were to have the console.log(word) within the method, what I want is returned. Any help/tips will be appreciated! Thank you!