ofetch
ofetch copied to clipboard
Errors not forwarded in hooks
When an error occurs in the onRequest hook, the error is not shown in the console and no request is send.
I would expect an error that occurs in the hook to still be shown in the console.
The following will create a fetch object that makes no requests, but prints no error.
$fetch.create({
async onRequest(ctx): Promise<void> {
throw "debug error"
}
})
The following code is working properly and logs "debug error 1" :
const f = $fetch.create({
onRequest(ctx): Promise<void> {
throw "debug error 1";
},
});
await f("http://httpstat.us/500");
@HydrofinLoewenherz Is this the behaviour that you expect ?
Let's track via https://github.com/unjs/ofetch/issues/396