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