@kelbyone/core
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -39,3 +39,3 @@ { | ||
}, | ||
"version": "0.0.5" | ||
"version": "0.0.6" | ||
} |
const uri = `https://kelbycerts.wpengine.com/wp-json/ko/v3`; | ||
export async function loadItems(type, category = null) { | ||
let url = `${uri}/${type}?per_page=24&token=w5a0c4fe21f4593.95564850`; | ||
let url = `${uri}/${type}?per_page=24`; | ||
if (category && category.id != 0) | ||
url = `${uri}/categories/${ | ||
category.id | ||
}/${type}?per_page=24&token=w5a0c4fe21f4593.95564850`; | ||
}/${type}?per_page=24`; | ||
return await load(url); | ||
@@ -13,3 +13,3 @@ } | ||
export async function loadItem(type, id) { | ||
const url = `${uri}/${type}/${id}?token=w5a0c4fe21f4593.95564850`; | ||
const url = `${uri}/${type}/${id}`; | ||
return await load(url); | ||
@@ -19,3 +19,3 @@ } | ||
export async function loadRelated(type, id, resource) { | ||
const url = `${uri}/${type}/${id}/${resource}?per_page=-1&token=w5a0c4fe21f4593.95564850`; | ||
const url = `${uri}/${type}/${id}/${resource}?per_page=-1`; | ||
return await load(url); | ||
@@ -30,3 +30,3 @@ } | ||
export async function loadCategories() { | ||
const url = `${uri}/categories/?token=w5a0c4fe21f4593.95564850`; | ||
const url = `${uri}/categories/`; | ||
return await load(url); | ||
@@ -33,0 +33,0 @@ } |
export { loadItems, loadItem, loadRelated } from './api-service'; | ||
export * from './user-service'; | ||
export * from './storage-service'; | ||
export * from './utils'; |
@@ -6,5 +6,11 @@ const storage = window.localStorage; | ||
try { | ||
window.dispatchEvent( | ||
new CustomEvent('storage:set', { key: key, value: value }) | ||
); | ||
storage && storage.setItem(key, JSON.stringify(value)); | ||
resolve(); | ||
} catch (err) { | ||
window.dispatchEvent( | ||
new CustomEvent('storage:error', { key: key, value: value, error: err }) | ||
); | ||
reject(`Couldn't store object ${err}`); | ||
@@ -18,5 +24,9 @@ } | ||
try { | ||
window.dispatchEvent(new CustomEvent('storage:remove', key)); | ||
storage && storage.removeItem(key); | ||
resolve(); | ||
} catch (err) { | ||
window.dispatchEvent( | ||
new CustomEvent('storage:error', { key: key, error: err }) | ||
); | ||
reject(`Couldn't remove object ${err}`); | ||
@@ -30,8 +40,9 @@ } | ||
try { | ||
if (storage) { | ||
const item = storage.getItem(key); | ||
resolve(JSON.parse(item)); | ||
} | ||
resolve(undefined); | ||
window.dispatchEvent(new CustomEvent('storage:get', key)); | ||
const item = storage.getItem(key); | ||
resolve(JSON.parse(item)); | ||
} catch (err) { | ||
window.dispatchEvent( | ||
new CustomEvent('storage:error', { key: key, error: err }) | ||
); | ||
reject(`Couldn't get object: ${err}`); | ||
@@ -38,0 +49,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
5346
137
3