master
parent
b7e316cc34
commit
3ba51c787a
|
@ -18,7 +18,7 @@ export async function sync() {
|
|||
let ids = items.map(obj => obj.id);
|
||||
|
||||
if (ids.length > 0) {
|
||||
let products = await fetch(url("contents/" + ids.join(",")));
|
||||
let products = await fetch(url("/contents/" + ids.join(",")));
|
||||
products = await products.json();
|
||||
|
||||
products.contents.forEach(product => {
|
||||
|
@ -93,5 +93,6 @@ export async function getTotalPrice() {
|
|||
|
||||
export async function getLink() {
|
||||
await sync();
|
||||
return url(btoa(JSON.stringify(items)));
|
||||
let miniItems = items.map(obj => { return { id: obj.id, quantity: obj.quantity } });
|
||||
return url("/?cart=" + btoa(JSON.stringify(miniItems)));
|
||||
}
|
|
@ -16,7 +16,7 @@ export function isEncoded(string) {
|
|||
}
|
||||
|
||||
export function url(path = "") {
|
||||
const baseUrlElement = document.getElementById("base-url");
|
||||
const baseUrlElement = document.querySelector('meta[name="url-base"]');
|
||||
const baseUrl = baseUrlElement ? baseUrlElement.getAttribute("content") : "";
|
||||
return baseUrl + path;
|
||||
}
|
Loading…
Reference in New Issue