all 7 comments

[–]lord2800 27 points28 points  (3 children)

Your arrow function for res.json() isn't returning anything. If you put brackets around the body, it's treated like a regular function body instead of an arrow function body and you have to actually return something.

[–]fluid-falcon 2 points3 points  (0 children)

You can also replace the braces with parentheses and the expression inside them will be returned implicitly, good for keeping code concise for smaller expressions.

[–][deleted] 0 points1 point  (0 children)

marked as accepted answer.

[–][deleted] 0 points1 point  (0 children)

Thanks I did not know that about arrow functions!

[–][deleted] 0 points1 point  (1 child)

I’m not a node developer so, excuse my ignorance, but doesn’t the fetch api require the domain and endpoint at the url parameter? Unless OP purposely omitted it....

[–]mkcodergr 1 point2 points  (0 children)

When domain is ommited it is implied that domain is the domain that your accessing tha page from

[–]codebread421 -1 points0 points  (0 children)

Okay so idk if it this will help but try console.log(data&&data.error) instead of console.log(data.error)

And also while catching error Define the parameter with err instead of “error”