Closed CrisChr closed 5 years ago
外部fetch.js: const api = 'https://api.douban.com/v2/movie/subject' export default { async movie(params) { const { syncParams: { movieId } } = params const rawResponse = await fetch(${api}/${movieId}) const textResponse = await rawResponse.text() const jsonResponse = JSON.parse(textResponse) //console.log('json: ', jsonResponse) if (jsonResponse) { storage.save({ key: 'movie', id: movieId, data: jsonResponse }) return jsonResponse } } } storage.js: const storage = new Storage({ size: 1000, storageBackend: AsyncStorage, defaultExpires: 1000 * 60 * 2, enableCache: true, sync: require('./src/data/fetchMovieDetails') }); 将storage.sync作为一个模块导入 后台一直报Expired error,无法从服务器更新数据
const api = 'https://api.douban.com/v2/movie/subject' export default { async movie(params) { const { syncParams: { movieId } } = params const rawResponse = await fetch(
) const textResponse = await rawResponse.text() const jsonResponse = JSON.parse(textResponse) //console.log('json: ', jsonResponse) if (jsonResponse) { storage.save({ key: 'movie', id: movieId, data: jsonResponse }) return jsonResponse } } }
const storage = new Storage({ size: 1000, storageBackend: AsyncStorage, defaultExpires: 1000 * 60 * 2, enableCache: true, sync: require('./src/data/fetchMovieDetails') });
外部fetch.js:
const api = 'https://api.douban.com/v2/movie/subject' export default { async movie(params) { const { syncParams: { movieId } } = params const rawResponse = await fetch(
${api}/${movieId}) const textResponse = await rawResponse.text() const jsonResponse = JSON.parse(textResponse) //console.log('json: ', jsonResponse) if (jsonResponse) { storage.save({ key: 'movie', id: movieId, data: jsonResponse }) return jsonResponse } } }
storage.js:const storage = new Storage({ size: 1000, storageBackend: AsyncStorage, defaultExpires: 1000 * 60 * 2, enableCache: true, sync: require('./src/data/fetchMovieDetails') });
将storage.sync作为一个模块导入 后台一直报Expired error,无法从服务器更新数据