N
Nuxt4w 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
isakwang4w 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
Cue4w 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
Mads4w ago
You should probably set ignoreResponseError to true. Assuming you use $fetch (useFetch) await $fetch('/api/used-cars/all', { method: 'GET', ignoreResponseError: true, })
isakwang
isakwang3w ago
yea sorry. I was thinking 401 and wrote the wrong thing if(!user) throw createError({code: '401', message: 'Unauthorized'})
Patrik
Patrik3w ago
So u still need help?
Want results from more Discord servers?
Add your server