Skip to content

Commit

Permalink
chore: check window params before use
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusgnreis committed May 7, 2024
1 parent 6849913 commit 67fccc9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/controllers/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
6 changes: 3 additions & 3 deletions src/script/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 67fccc9

Please sign in to comment.