When I include "{ observe: 'response' }" in my request, why do I encounter an error (ERROR TypeError: Cannot read properties of undefined (reading 'pipe'))? This is to retrieve all headers.
let answer = this.http.post<ResponseLoginHttp>(AUTH_API + "login", json_data, { observe: 'response' });
let answer2
answer.subscribe(value => {
this.dataService.setResponceLoginHttp(value.body);
answer2 = value.body
})
return answer2.pipe(
map((data) => {
return data;
}),
catchError((error) => {
console.log("Error - ", error);
throw new Error(error.message);
})
);}
However, when I remove "{ observe: 'response' }", everything works as expected:
let answer = this.http.post<ResponseLoginHttp>(AUTH_API + "login", json_data );
answer.subscribe(value => {
this.dataService.setResponceLoginHttp(value);
})
return answer.pipe(
map((data) => {
return data;
}),
catchError((error) => {
console.log("Error - ", error);
throw new Error(error.message);
})
);}
Is there a way to retrieve all the headers from the response without triggering the "ERROR TypeError: Cannot read properties of undefined (reading 'pipe')" error?