From 4553d648b7d536b1ab42faa552f38eaca319b7b8 Mon Sep 17 00:00:00 2001 From: Leonardo Matos Date: Tue, 9 Jul 2019 18:46:40 -0300 Subject: [PATCH] fix(request-store-api): fix handling chosing cache or live api host --- src/methods/request-store-api.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/methods/request-store-api.js b/src/methods/request-store-api.js index 81e1f2f..43ec612 100644 --- a/src/methods/request-store-api.js +++ b/src/methods/request-store-api.js @@ -22,9 +22,14 @@ const requestStoreApi = ( // first check if it's a public request if (method.toLowerCase() === 'get' && !authenticationId) { // less timeout for public requests - timeout = 5000 - // use cache API host for public requests - baseURL = isCacheOnline ? API_STORE_CACHE : API_STORE + if (isCacheOnline && !/\?/.test(url) && (!axiosConfig || !axiosConfig.params)) { + // use cache API host + timeout = 2500 + baseURL = API_STORE_CACHE.replace(':id', storeId) + } else { + timeout = 5000 + baseURL = API_STORE + } } else { baseURL = API_STORE // setup authentication headers