Closed kivervinicius closed 4 years ago
pls provide the detail error stack
The get function may returns null if it invoked before the value set to sessionStorage until the promise resolved. you may need to combine a memory cache with a persist cache to support your requirement.
Solution for your requirement:
const map = new Map();
export default {
async get (index) {
return map.get(index) || sessionStorage.getItem(index);
},
async set (index, value) {
map.set(index, value);
const v = await value;
sessionStorage.setItem(index, JSON.parse(JSON.stringify(v)));
},
del (index) {
console.log("del", index);
map.delete(index);
sessionStorage.removeItem(index);
},
};
When using a cache like function, the get method if a promise returns null and no and the error in the axios adapter function.
example: this example i use sessionStorage but i use localforage in production