I am trying to print out the response that I get from my HTTP GET
request.
Problem is that I get an error in my console:
ERROR TypeError: Cannot read property 'id' of undefined
REQUEST CODE:
@Effect()
bucketsFetch = this.actions$
.ofType(BucketActions.FETCH_BUCKETS)
.switchMap(() => {
console.log('Sending GET request to Server');
return this.httpClient
.get<Bucket[]>('/storage/buckets', {
observe: 'body',
responseType: 'json'
});
})
.map(
(buckets) => {
console.log('Received bucket:' + buckets[0].id);
return {
type: BucketActions.SET_BUCKETS,
payload: buckets
};
}
);
The error is throwing at the part where I try to console.log
my response. The Bucket
Model is correct 100% and it should return an array of Buckets as per API description, but still I get this error.
So in order to investigate further, I would like to print out the JSON response from my request, to see what it returns.
How can I do that?
Aucun commentaire:
Enregistrer un commentaire