Non fatal server error
Hello
How can I return a non fatal server error? As soon as I set the response header as 201 for example it is treated as a fatal error, when I just want to treat it as a form error
5 Replies
I can just return an object called error with a message, but I would like for the headers to be correct if possible
Setting 201 status code isn't treated as a fatal error, it is a successful status code. Could you provide something to reproduce?
You should probably set ignoreResponseError to true. Assuming you use $fetch (useFetch)
await $fetch('/api/used-cars/all', {
method: 'GET',
ignoreResponseError: true,
})
yea sorry. I was thinking 401 and wrote the wrong thing
if(!user) throw createError({code: '401', message: 'Unauthorized'})
So u still need help?