I am using httpclient request to get data from wordpress API, and in response I am getting error. It seems issue with Array in response. here what is the code I am using
getTetimonialData() {
this.http.get<{ testimonials: any }>(BASE_URL + '/testimonial/').pipe( map( testimonialsData => {
// return testimonialsData;
return {
testimonials: testimonialsData.testimonials.map(testData => {
return {
id: testData.id,
date: testData.date,
slug: testData.slug,
title: {
rendered: testData.title.rendered,
},
yoast_meta: {
yoast_wpseo_title: testData.yoast_meta.yoast_wpseo_title,
yoast_wpseo_metadesc: testData.yoast_meta.yoast_wpseo_metadesc,
yoast_wpseo_canonical: testData.yoast_meta.yoast_wpseo_canonical,
},
acf: {
video_url: testData.acf.video_url,
video_image: {
url: testData.acf.video_image.url,
alt: testData.acf.video_image.alt,
}
}
};
})
};
})).subscribe(transformData => {
this.testimonials = transformData.testimonials;
console.log(this.testimonials);
this.testimonialFetch.next(this.testimonials);
});
}
and here is the error
ERROR TypeError: Cannot read property 'map' of undefined
I have even tried to use tesimonialData.map as response is already in Array, but this also shows warring that testimonial type any not allowed.
This Error is for line where i am looping through data not with the rxjs map function.
so is I am doing something wrong?

testimonialsDatalooks like when youconsole.log(...)it?