diff --git a/src/client/api.ts b/src/client/api.ts index 9bb7386..f004f8b 100644 --- a/src/client/api.ts +++ b/src/client/api.ts @@ -41,14 +41,17 @@ export const load = (id: string) => return res; }); +var version_add = 1 export const save = async (id: string, v: journey) => { - v.version +=1; - return fetch("/api/" + id, { method: "post", body: JSON.stringify(v) }) + let body = JSON.parse(JSON.stringify(v)) + body.version +=version_add; + return fetch("/api/" + id, { method: "post", body: JSON.stringify(body) }) .then((res) => { if (!res.ok) throw new Error("Error " + res.statusText); return res.json(); }) .then((_res) => { + version_add+=1; console.log("Saved..."); }); }