Gaëtan Penotet
Have fetch requests returning an error code when
Hi everyone.
I have had no luck with this, coule you please give me a hand?
I have a ts file (note a component) where I try to ping assets urls to assert that they exist.
Once in spa it works (at least in electron where I use it)
I do a simple return fetch( path, { method: 'HEAD' } ).then( good).catch(bad);
But it doesn't work in dev mode and I can't test things properly.
The issue being that nuxt never sends a error code for a request, but some html content (the 404 page).
Here is an example, where I try to ping (result in the console) and download (result displayed) two files, one that exists and one that doesn't. Even for the file that doesn't exist I get a code 200 and some content.
https://codesandbox.io/p/devbox/gracious-torvalds-t54zkh
How can I configure either Nuxt or my request (some special header maybe?) to actually get an error code for my request when an asset doesn't exist ?
Thanks a lot 👌
1 replies