the back generates an error 400 which is normal.
i want to intercept the error on angular to process it.
createRecord(): Observable<any> {
const headers = new HttpHeaders().set("keyidentity", keyidentity);
return this._httpClient.post(`${requestUrl}`, equipe, { headers });
}
(1)
this.createRecord()
.pipe(catchError((error: any, caught: Observable<any>): Observable<any> => {
console.error(error); // ???
return of();
}))
.subscribe(() => {
});
(2)
this.createRecord(requestUrl, delegationPost, this._authentificationService.getConnectedIdentity()).subscribe({
next: () => {
},
error: (error: any) => {
console.log(error); // ??
}
});
(1) and (2)
TypeError: You provided 'null' where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.
at createInvalidObservableTypeError (throwUnobservableError.js:2:12)
at innerFrom (innerFrom.js:37:43)
at catchError.js:10:38
I don't understand this error, how can I resolve it? I'd like to get the content of the error in the reply to the request I have :
{
"entityName": "La délégation existe déjà",
"errorKey": "La délégation existe déjà",
"type": "/problem-with-message",
"title": "La délégation existe déjà",
"status": 400,
"message": "error.La délégation existe déjà",
"params": "La délégation existe déjà"
}
console.log(error); // doesn't display the content of the answer?