Overriding handleError
"angular2-jsonapi": "^8.2.1"
In readme is stated 'It's also possible to handle errors for all requests by overriding handleError(error: any): Observable in the datastore.'.
So i'm interested how can i achieve this behaviour? This is auth datastore and should it be possible to override it in here.
const config: DatastoreConfig = {
baseUrl: ${environment.baseUrl}/auth,
models: {
login: Login,
refresh: Refresh,
},
};
@Injectable({
providedIn: 'root',
})
@JsonApiDatastoreConfig(config)
export class DatastoreService extends JsonApiDatastore {
constructor(public http: HttpClient) {
super(http);
}
}
Thanks :)
This seems to be an incorrect statement in the README, because the only methods that can be overwritten are
-
getDirtyAttributes -
toQueryString
The override mechanism is described here and it works by adding the overwriting methods in the overrides property of the datastore config object.
But you could implement this method in a PR similar to the above methods: https://github.com/ghidoz/angular2-jsonapi/blob/master/projects/angular2-jsonapi/src/services/json-api-datastore.service.ts#L33