Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

403 Forbidden Response Doesn't Throw Exception #469

Open
XDGFX opened this issue May 2, 2024 · 0 comments
Open

403 Forbidden Response Doesn't Throw Exception #469

XDGFX opened this issue May 2, 2024 · 0 comments

Comments

@XDGFX
Copy link

XDGFX commented May 2, 2024

I'm using mande to send a post request to a server. Sometimes the server returns a 403 response, so I expect the .post() method to throw an exception, however it doesn't.

Client side code:

try {
    const renew = mande(SERVER_URL + '/api/v1/token/renew');
    const res = await renew.post<ApiRes<'/token/renew', 'POST'>>();

    token = res.token;
    id = res.id;
    expires = res.expires;
} catch (error) {
    console.error('Failed to renew token:', error);
    logout();
    return;
}

However the catch block never runs, I get this error in the browser console

[XHR]POST.   http://localhost:3478/api/v1/token/renew.  [HTTP/1.1 403 Forbidden 34ms]

Using Firefox 125.0.3 on macOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants