How do I return custom HTTP error codes? #316
Replies: 2 comments 1 reply
-
maybe: import { createSafeAction } from 'next-safe-action';
export const myAction = createSafeAction(async (input, context) => {
// logic here
if (userAlreadyExists) {
context.res.status(409); // status code 409
throw new Error('USER ALREADY EXISTS');
}
// other logic
}); this help you? |
Beta Was this translation helpful? Give feedback.
0 replies
-
You can't return a different HTTP code. It's either |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using next safe action to call my server actions. The errors are being shown on screen properly but the network tab still shows 200 for a "USER ALREADY EXISTS" instead of 400 or 409. Even when I tried returning my custom error from the action, the network tab still shows 200. How do I handle this?
Beta Was this translation helpful? Give feedback.
All reactions