WaspW
Wasp14mo ago
Sven

I want to return a 401 status on an action when a certain error occurs

Hi kapa, i want to return a response of 401 when a certain action fails. In my case my action fetches some information from an external API but when this fails with a 401 status i want to also return a 401 status to the client.

       const response = await axios.post(tokenUrl, {}, { headers });
        if (response.status === 401) {
            throw new HttpError(401, 'Bs'); 
        }


Right now i do the following above but it throws the error but does still return a 200 to the client.
Was this page helpful?