You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead I got TypeError: undefined is not a function
It seems like res.json and res.send aren't available if a Router is used standalone without Express. Is this by design? I couldn't find anything about it in the docs or in past issues.
The text was updated successfully, but these errors were encountered:
This is by design, as those are not part of routing a request. The router just routes requests to handles. Anything the router provides should be in the README in the repository (and it doesn't call out to everything not included, as that would be a pretty much endless list--if it's not in the docs, it can be assumed to not exist).
With the router, your req and res will simply look like however they looked when you passed them into the main router function. In your example, you are passing what comes from http.createServer, so the methods on those objects are documented in node.js:
I've been working on an example for the docs for #36 but the following didn't work for me:
Instead I got
TypeError: undefined is not a function
It seems like
res.json
andres.send
aren't available if a Router is used standalone without Express. Is this by design? I couldn't find anything about it in the docs or in past issues.The text was updated successfully, but these errors were encountered: