Closed alexicum closed 8 years ago
How are you using it? Try to add a .catch(error => console.error(error))
to your service calls (e.g. app.service('myservice').then().catch(error => console.error(error))
) to see if there is an error.
Thanks! It helps to understand what's going on without examples.
Previously I had successfully remove item without id with command:
Storage.remove(Number.NaN);
Now I have item with "id":null
(don't ask me how :) )
and no ideas about how to remove it.
Receiving:
Error: No record found for id 'null'(…)
with both code:
Storage.remove(null);
Storage.find()
.then(tokens)
for(let token of tokens) {
Storage.remove(token.id)
.then((removedToken) => {
if (removedToken)
console.log('removed: ' + JSON.stringify(removedToken));
})
.catch(error => console.error(error));
...
My storage items:
find(). tokens array: [{"id_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImEiLCJpZCI6MiwiaWF0IjoxNDY4MzE0Mzk2LCJleHAiOjE0NjgzMzIzOTZ9.Vep46JizCMLc03bL0-SXpxf1MG6LCduzkGGkOlG_BW8","id":1},{"id_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImEiLCJpZCI6MiwiaWF0IjoxNDY4MzE0MDk0LCJleHAiOjE0NjgzMzIwOTR9.iL3WrUkjvqAHwusBH6KoQCjigS7TDZAAKLJBSIHjwJw","id":null}]
The id being null
shouldn't really be possible but you can probably remove it manually from AsyncStorage with something like
const storageKey = 'feathers';
AsyncStorage.getItem(storageKey).then(JSON.parse)
.then(data => data.filter(current => current.id !== null)).
.then(filteredData => AsyncStorage.setItem(storageKey, JSON.stringify(filteredData));
Trying to use feathers-localstorage with React Native and AsyncStorage.
Hang on create, get. Can not find RN example on base service functions: get, update, remove.
Documentation has code for ReactNative with:
import feathers from 'feathers';
But in chat example:import feathers from 'feathers/client'