If I overwrite the default create endpoint using custom endpoints within a collection, and I get the newly created object ID {insertedId: id}, which return statement can help me prevent /api/collection/undefined? res.status(200).send("what should be here?")
What is the correct response to prevent "undefined" in custom endpoints?
Good morning, I currently don’t know your direct use case. If you need it directly, you should return the newly created id.
Otherwise you should return HTTP Status code 201 created
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201Thanks alot, the 201 status code helped and what I was looking for was const response = {message: "my message", doc: payload} and the payload includes the id and other document properties.
👍
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.