Skip to content

Customize Rest API response in collection hooks #5691

Answered by DanRibbens
rk54rk asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @rk54rk,

You can import APIError from 'payload/errors' and instead of return Promise.reject, you'd have throw New APIError(message, 429)

There are other Error types you can choose from if you wish also.

I hope that answers your question, let me know if you need anything else!

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by rk54rk
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants