Reputation: 1
Good afternoon, all react-admin users. I am using this awesome open-source project and I have been struggling for hours.
As stated in the documentation, if any API calls return any error, the authProvider will catch it with type AUTH_ERROR. However, in my case, authProvider is not triggered. Thank you for reading this. Any help would be much appreciated.
AuthProvider:
export default async(type, params) => {
if (type === AUTH_ERROR) console.log('testing')
}
dataProvider:
class dataProviderHttpError extends Error {
constructor(status, message) {
super(message)
this.status = status
}
}
export default (type, resource, params) => {
return Promise.reject(new dataProviderHttpError(401, 'testing'))
}
Admin
import dataProvider from './dataProvider'
<Admin
dataProvider={dataProvider}
/>
Upvotes: 0
Views: 549
Reputation: 459
authProvider will catch any authentication error you make it listen for and return a Promise.reject()
On your example you just tell your authProvider to show something on your console and then on your dataProvider you try to return a Promice.reject()
.
This is a task for your authProvider, not your dataProvider.
You can check again the part of the documentation that explains how to handle AUTH_ERRORS on the authProvider here.
Upvotes: 1