Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

fix(theme): update contextToken only if has changed #195

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/composables/src/hooks/useCart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export const useCart = (): any => {
vuexStore.commit("SET_CART", result);
} catch (e) {
error.value = e;
console.error("Problem with fetching data", e.message);
console.error("Problem with fetching CART data", e.message);
console.error(e);
} finally {
loading.value = false;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/composables/src/hooks/useCms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export const useCms = (): any => {
vuexStore.commit("SET_PAGE", result);
} catch (e) {
error.value = e;
console.error("Problem with fetching data", e.message);
console.error("Problem with fetching CMS data", e.message);
console.error(e);
} finally {
loading.value = false;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/composables/src/hooks/useProduct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export const useProduct = (
return result;
} catch (e) {
error.value = e;
console.error("Problem with fetching data", e.message);
console.error("Problem with fetching PRODUCT data", e.message);
console.error(e);
} finally {
loading.value = false;
}
Expand Down
10 changes: 7 additions & 3 deletions packages/default-theme/plugins/api-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ export default ({ app, store }) => {
* Save current contextToken when its change
*/
onConfigChange(({ config }) => {
app.$cookies.set('sw-context-token', config.contextToken, {
maxAge: 60 * 60 * 24 * 365
})
try {
app.$cookies.set('sw-context-token', config.contextToken, {
maxAge: 60 * 60 * 24 * 365
})
} catch (e) {
// Sometimes cookie is set on server after request is send, it can fail silently
}
})

// Temporary fix for SSR and reactivity
Expand Down