我在Ionic应用程序上使用woocommerce API 我尝试将应用程序与Wordpress连接出现错误 picture
已经阅读了发行API的文档 documentation foodmall
1)在this.service.currencies ....
中错误加载货币loadCurrency() {
let subscription: Subscription = this.service.currencies(window.localStorage.getItem(Constants.ADMIN_API_KEY)).subscribe(data => {
let currency: Currency = data;
window.localStorage.setItem(Constants.CURRENCY, JSON.stringify(currency));
console.log('currency setup success');
}, err => {
console.log('currency setup error');
});
this.subscriptions.push(subscription);
}
2)此.service.categories .....
中的错误加载类别loadCategories() {
let subscription: Subscription = this.service.categories(window.localStorage.getItem(Constants.ADMIN_API_KEY), String(this.pageCategory)).subscribe(data => {
let categories: Array<Category> = data;
if (categories.length == 0) {
window.localStorage.setItem(Constants.PRODUCT_CATEGORIES, JSON.stringify(this.categoriesAll));
console.log('categories setup success');
this.events.publish('category:setup');
} else {
this.categoriesAll = this.categoriesAll.concat(categories);
this.pageCategory++;
this.loadCategories();
}
}, err => {
console.log('loadCategories setup error');
});
this.subscriptions.push(subscription);
}
遵循类别的服务
public categories(adminToken: string, pageNo: string): Observable<Array<Category>> {
const myHeaders = new HttpHeaders({ 'Content-Type': 'application/json', 'Authorization': adminToken });
return this.http
.get<Array<Category>>(this.config.apiBase + 'wc/v2/products/categories/?per_page=20&order=desc&orderby=count&page=' + pageNo + '&_embed', { headers: myHeaders })
.concatMap(data => {
return Observable.of(data);
});
}
请提供解决方案,对于我的英语不好:/