[英]Ionic Storage not outputing my stored JSON data correctly - Angular
I have something like the following:我有以下内容:
Storage.remove({key: 'somedata'}).then(r => {
Storage.set({key: 'somedata', value: data}).then(g => {
Storage.get({key : 'somedata'}).then((val) => {
console.log('Your json is', val);
});
});
});
I get data from my API in JSON from and try to store it.我从 JSON 中的 API 获取数据并尝试存储它。
When I then try to output the stored data in the console I get the following然后当我尝试 output 存储在控制台中的数据时,我得到以下信息
I am wondering how I can get the acctual data instead of it being object object我想知道如何获取实际数据而不是 object object
Thanks谢谢
Update - Picture of error with potential solution更新 - 带有潜在解决方案的错误图片
I think you don't need to remove我认为你不需要删除
Storage.set(key, data).then(g => {
Storage.get(key).then((val) => {
console.log('Your json is', val);
});
});
In my opinion, I think you can try this在我看来,我认为你可以试试这个
Storage.remove({key: 'somedata'}).then(r => {
Storage.set({key: 'somedata', value: JSON.stringify(data)}).then(g => {
Storage.get({key : 'somedata'}).then((val) => {
console.log('Your json is', JSON.parse(val));
});
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.