skinny-azureS
Refine3y ago
4 replies
skinny-azure

handling errors and accessing objects

    onError: async (error) => {
        console.log(error);
        if (
            error.status === 401 ||
            error.status === 403 ||
            error.message === "Request failed with status code 401" ||
            error.message === "Request failed with status code 403"
        ) {
            return {
                logout: true,
                redirectTo: "/login",
                error,
            };
        }

        return {};
    },

i am trying to handle 401 and 403 is there a way i can get status code access because as you can see handling error with error message what i have been doing and the error object
Error: Request failed with status code 401
    at createError (createError.js:16:15)
    at settle (settle.js:17:12)
    at XMLHttpRequest.onloadend (xhr.js:66:7)

is not enough no response no status code access
Was this page helpful?