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) =>
|
||||
this.cache
|
||||
.get(cacheKey)
|
||||
.catch(() => fetch(url, options)) // else fetch fresh data
|
||||
.then(successfullResponse)
|
||||
.then(results => this.cache.set(cacheKey, results, 21600)) // 6 hours
|
||||
.catch(error => {
|
||||
// else fetch fresh data
|
||||
return fetch(url, options)
|
||||
.then(successfullResponse)
|
||||
.then(results => this.cache.set(cacheKey, results, 21600)); // 6 hours
|
||||
})
|
||||
.then(mapResults)
|
||||
.then(resolve)
|
||||
.catch(error => {
|
||||
|
||||
Reference in New Issue
Block a user