TypeError: res.json is not a function
I got this error message because I had the arguments in the wrong order in the handler method. (amateur's fault)
Wrong order: (res, req)
app.get('/json', (res, req) => {
res.json({
"message": "Hello json"
});
});
Right order: (req, res)
app.get('/json', (req, res) => {
res.json({
"message": "Hello json"
});
});
Because you're overwriting your res
variable in the .then
of your rp
function:
app.post('/danger', function response(req, res) { //see, "res" here was being overwritten
..
..
rp(option).then(function(response) { //change the variable name of "res" to "response" (or "turtles", who cares, just dont overwrite your up most "res")