Skip to content

Commit

Permalink
style: prettified code
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurfiorette committed Sep 11, 2021
1 parent 892dab4 commit 6ae6d8f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/interceptors/response.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AxiosCacheInstance } from '../axios/types';
import { checkPredicateObject } from '../util/cache-predicate';
import { updateCache } from '../util/update-cache';
import {checkPredicateObject} from '../util/cache-predicate'

export function applyResponseInterceptor(axios: AxiosCacheInstance): void {
axios.interceptors.response.use(async (response) => {
Expand All @@ -9,15 +9,16 @@ export function applyResponseInterceptor(axios: AxiosCacheInstance): void {
updateCache(axios, response.data, response.config.cache.update);
}

const cachePredicate = response.config.cache?.cachePredicate || axios.defaults.cache.cachePredicate;
const cachePredicate =
response.config.cache?.cachePredicate || axios.defaults.cache.cachePredicate;

// Config told that this response should be cached.
if (typeof cachePredicate === 'function') {
if(!cachePredicate(response)) {
if (!cachePredicate(response)) {
return response;
}
} else {
if(!checkPredicateObject(response, cachePredicate)) {
if (!checkPredicateObject(response, cachePredicate)) {
return response;
}
}
Expand Down

0 comments on commit 6ae6d8f

Please sign in to comment.