From 67fccc99e81b8a51df3754067dc7d911662e87d7 Mon Sep 17 00:00:00 2001 From: matheusgnreis Date: Tue, 7 May 2024 08:45:39 -0300 Subject: [PATCH] chore: check window params before use --- src/controllers/resources.js | 2 +- src/script/main.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controllers/resources.js b/src/controllers/resources.js index 92b7c3fc..cf07f45b 100644 --- a/src/controllers/resources.js +++ b/src/controllers/resources.js @@ -555,7 +555,7 @@ export default function () { const id = Tab.selectedItems[done] if (id) { - const isApiv2 = Number(window.localStorage.getItem('api_version')) === 2 || window.ECOMCLIENT_API_STORE.indexOf('v2') > -1 + const isApiv2 = Number(window.localStorage.getItem('api_version')) === 2 || window.ECOMCLIENT_API_STORE && window.ECOMCLIENT_API_STORE.indexOf('v2') > -1 const apiBaseUri = isApiv2 ? 'https://ecomplus.io/v2' : 'https://api.e-com.plus/v1' askConfirmation( `${apiBaseUri}/${slug}/${id}.json`, diff --git a/src/script/main.js b/src/script/main.js index 4d8890ee..471446f6 100644 --- a/src/script/main.js +++ b/src/script/main.js @@ -27,7 +27,7 @@ import EventEmitter from 'eventemitter3' const { sessionStorage, localStorage, Image, $, app } = window -const isApiv2 = Number(sessionStorage.getItem('api_version')) === 2 || window.ECOMCLIENT_API_STORE.indexOf('v2') > -1 +const isApiv2 = Number(sessionStorage.getItem('api_version')) === 2 || window.ECOMCLIENT_API_STORE && window.ECOMCLIENT_API_STORE.indexOf('v2') > -1 console.log('which api', isApiv2) ;(function () { @@ -226,7 +226,7 @@ console.log('which api', isApiv2) hideToast() // E-Com Plus Store API // https://ecomstore.docs.apiary.io/# - const isApiv2 = Number(sessionStorage.getItem('api_version')) === 2 || window.ECOMCLIENT_API_STORE.indexOf('v2') > -1 + const isApiv2 = Number(sessionStorage.getItem('api_version')) === 2 || window.ECOMCLIENT_API_STORE && window.ECOMCLIENT_API_STORE.indexOf('v2') > -1 const apiBaseUri = isApiv2 ? 'https://ecomplus.io/v2' : 'https://api.e-com.plus/v1' // API endpoint full URL var uri = apiBaseUri + '/' + endpoint @@ -324,7 +324,7 @@ console.log('which api', isApiv2) var callSearchApi = function (endpoint, method, callback, bodyObject) { // E-Com Plus Search API // https://ecomsearch.docs.apiary.io/# - const isApiv2 = Number(sessionStorage.getItem('api_version')) === 2 || window.ECOMCLIENT_API_STORE.indexOf('v2') > -1 + const isApiv2 = Number(sessionStorage.getItem('api_version')) === 2 || window.ECOMCLIENT_API_STORE && window.ECOMCLIENT_API_STORE.indexOf('v2') > -1 const apiBaseUri = isApiv2 ? 'https://ecomplus.io/v2/search/_els' : 'https://apx-search.e-com.plus/api/v1' // API endpoint full URL let uri