X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fstore.js;h=668f999d3af77aa2c99f8291154ddab7b35fd2de;hb=6b7b2cf720e6255e4da0dc34fee363c456346a58;hp=705f473c0fec795ca949445e42f540dccb285db5;hpb=f35b9960e1c527fc400ebac85321bd4712459da3;p=vchess.git diff --git a/client/src/store.js b/client/src/store.js index 705f473c..668f999d 100644 --- a/client/src/store.js +++ b/client/src/store.js @@ -13,12 +13,23 @@ export const store = { }, socketCloseListener: null, initialize() { + const headers = { + "Content-Type": "application/json;charset=UTF-8", + "X-Requested-With": "XMLHttpRequest" + }; fetch( params.serverUrl + "/variants", - {method: "GET"}, + { + method: "GET", + headers: headers + } ) .then(res => res.json()) .then(json => { + if (!Array.isArray(json.variantArray)) { + alert("Variants loading failed: reload the page"); + return; + } this.state.variants = json.variantArray.sort( (v1,v2) => v1.name.localeCompare(v2.name)); }); @@ -42,6 +53,7 @@ export const store = { params.serverUrl + "/whoami", { method: "GET", + headers: headers, credentials: params.credentials } ) @@ -77,6 +89,7 @@ export const store = { sound: getItemDefaultTrue("sound"), hints: getItemDefaultTrue("hints"), highlight: getItemDefaultTrue("highlight"), + gotonext: getItemDefaultTrue("gotonext"), randomness: parseInt(localStorage.getItem("randomness")) }; if (isNaN(this.state.settings.randomness))