N
Nuxt3mo ago
isakwang

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
isakwang
isakwangOP3mo ago
I can just return an object called error with a message, but I would like for the headers to be correct if possible
Cue
Cue3mo ago
Setting 201 status code isn't treated as a fatal error, it is a successful status code. Could you provide something to reproduce?
Mads
Mads3mo ago
You should probably set ignoreResponseError to true. Assuming you use $fetch (useFetch) await $fetch('/api/used-cars/all', { method: 'GET', ignoreResponseError: true, })
isakwang
isakwangOP3mo ago
yea sorry. I was thinking 401 and wrote the wrong thing if(!user) throw createError({code: '401', message: 'Unauthorized'})
Patrik
Patrik3mo ago
So u still need help?
Want results from more Discord servers?
Add your server