Skip to content

Conversation

@jkeruzec
Copy link

@jkeruzec jkeruzec commented Oct 1, 2018

Hello,

I wanted to do this PR that I found useful for my project :
When creating APIClient, provide an errorCallback method that will be called in case of rest fetch error

How to use it :

const handleErrors = (error) => {
    if(error.status === 401)) {
        loginServices.invalidateUser();
        window.location = '/'; 
    }
}
const options = {
     apiPath: apiPath,
     commonOptions: {
         errorCallBack : handleErrors
     }
}
       
return apiClient(adapter, options);

@jkeruzec
Copy link
Author

@masylum Any chance to have this integrated to the library ?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant