To keep cache response & api response consistent, alter call chain
This commit is contained in:
@@ -194,9 +194,12 @@ class Plex {
|
|||||||
return new Promise((resolve, reject) =>
|
return new Promise((resolve, reject) =>
|
||||||
this.cache
|
this.cache
|
||||||
.get(cacheKey)
|
.get(cacheKey)
|
||||||
.catch(() => fetch(url, options)) // else fetch fresh data
|
.catch(error => {
|
||||||
|
// else fetch fresh data
|
||||||
|
return fetch(url, options)
|
||||||
.then(successfullResponse)
|
.then(successfullResponse)
|
||||||
.then(results => this.cache.set(cacheKey, results, 21600)) // 6 hours
|
.then(results => this.cache.set(cacheKey, results, 21600)); // 6 hours
|
||||||
|
})
|
||||||
.then(mapResults)
|
.then(mapResults)
|
||||||
.then(resolve)
|
.then(resolve)
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
|||||||
Reference in New Issue
Block a user