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
The route handlers retain their original express signature (req, res).
You can use the res object to send a custom status code. For instance: res.status(201).
Note that if you chose to use the res object, then you must send your response manually using the regular express api (res.send() or res.write(), etc...). rest.ts ignores the returned value as you can see here.
Here is an example of how to do this:
buildRouter(myCustomAPI,(builder)=>builder.listPublications(async(req,res)=>{res.status(404).send('Sorry, we cannot find that!');});
_Note that marking the function async is a good idea to make sure that res.send is invoked before the promise returned by the handler resolves.
I don't see how I would send status codes with the buildRouter API -- help?
The text was updated successfully, but these errors were encountered: