例如如何正确存储用户,例如[{username:'username',name:'name',surname:'surname'},{username:'username1',name:'name1',surname:'surname1' }]?只是喜欢这个代码吗?
return AsyncStorage.getItem('users')
.then(req => JSON.parse(req))
.then(json => {
json.push(newUser);
return AsyncStorage.setItem('users', JSON.stringify(json))
.then(json => console.log('success!'))
.catch(error => console.log(error));
})
.catch(error => console.log(error));