我正在使用Ionic 3将一些参数发布到URL,并且我在下面收到了JSON
{
channel: {
id: 9164115,
name: "STATION AT SA BI",
description: "With DIC DIU",
latitude: "0.0",
longitude: "0.0",
created_at: "2017-07-01T09:09:23+03:00",
updated_at: "2018-01-22T01:52:04+03:00",
last_entry_id: 498718
},
feeds: [
{
created_at: "2017-07-01T09:09:23+03:00",
field2: "3.3088235294117645"
},
{
created_at: "2017-07-01T09:09:23+03:00",
field2: "3.736666666666667"
},
{
created_at: "2017-07-01T09:09:23+03:00",
field2: "3.9456666666666664"
},
{
created_at: "2017-07-01T09:09:23+03:00",
field2: "3.706521739130434"
}
]
}
我读了从URL返回的JSON,如下所示
var data = {'channel': '9164115', 'field': 'XJ' }
try {
this.restProvider.postData("http://apiurl.com/list", data).then((result) => {
console.log(result); // DISPLAYS JSON IN CONSOLE
this.last_updateDate = result.channel.updated_at; // FAILS
}, (err) => {
console.log(err);
});
} catch (e){
console.log(e);
}
我能够在我的控制台中打印出JSON并查看它,但是当我尝试读取它的对象时,我收到了这个错误。
Property 'channel' does not exist on type '{}'.
我已经在网上查看了几个解决方案,但似乎没有一个适合我的情况。
如何摆脱此错误?