[英]Unable to make HttpClient post request in Angular because of CORS issue
[英]issue with httpclient request Array in Angular
我正在使用httpclient請求從wordpress API獲取數據,作為響應,我遇到了錯誤。 似乎Array有問題。 這是我正在使用的代碼
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);
});
}
這是錯誤
ERROR TypeError: Cannot read property 'map' of undefined
我什至嘗試使用tesimonialData.map
因為響應已經在Array中了,但這也顯示了tesimonialData.map
,不允許任何推薦類型。
此錯誤適用於我不使用rxjs map函數遍歷數據的行。
所以我做錯了嗎?
您能否回答這個問題以及Angular Resolver問題
對不起,沒有太多聲譽可言
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.