javascript – TypeError: res.json is not a function
javascript – TypeError: res.json is not a function
Because youre 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)
.json
isnt a function. Unless you are using a library that makes it one, JavaScript uses JSON
(with two methods .parse()
and .stringify()
one of which you use in the line above).
If you are trying to set an object property by the name of .json
then it would be:
res.json = {data: [res, dangerRate]};
javascript – TypeError: res.json is not a function
With new httpClient libary, you dont need to call .json() method, Just use this simple map instead of the json method.
.map(res => res );
Related posts on JavaScript :
- What is JavaScript useful for?
- What is import from in JavaScript?
- How do I add JavaScript to Chrome?
- How do you link externally in JavaScript?
- Can you embed JavaScript in WordPress?
- How do you swap an image in JavaScript?
- Does WordPress allow custom JavaScript?
- Does JavaScript have a stack?
- What is a call in JavaScript?
- What is .trim JavaScript?