On the client side, I send a JWT to the backend API for certain requests. If there is some issue with the JWT or it's not refreshed, I want to cancel everything and direct the user to the sign-in page.
async getData() { const authHeaders = await this.getHeaders(); if (authHeaders === null) { await goto('/sign-in'); throw new Error('Goto failed'); } ... }
My understanding is that the throw new Error('Goto failed');
line would not be reached, but I am noticing that exception come up and wondering how this could happen?
Using SvelteKit 2.5.7
Originally, I didn't have the await
in front of goto and added that in. I added in the throw new Error
just to make sure code after the goto was being reached. I've looked through svelte documentation and don't see this issue mentioned