我有离子/角度项目。
我通过以下方式调用外部 api:
public getKeys() {
this.http.get('https://api.apify.com/v2/key-value-stores/myStorage/keys')
.subscribe(
data => this.dataKeys,
err => this.handleError(err)
);
}
我的问题是,即使我从服务器得到有效的响应:
{
"data": {
"items": [
{
"key": "1",
"size": 52
},
{
"key": "2",
"size": 60
}
],
"count": 2,
"limit": 1000,
"exclusiveStartKey": null,
"isTruncated": false,
"nextExclusiveStartKey": null
}
}
它不会保存到 this.dataKeys。我打电话给这个:
ngOnInit() {
this.createStorage();
console.log(this.dataStorage);
this.getKeys();
console.log(this.dataKeys);
this.players.push(this.player);
console.log(this.players);
this.postData(JSON.parse(JSON.stringify(this.player)), "3");
this.getKeys();
console.log(this.dataKeys);
}
并且来自 api 的所有日志都未定义。每一个帮助将不胜感激。