X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fstore.js;h=668f999d3af77aa2c99f8291154ddab7b35fd2de;hp=c98657ef50f2d4df1316a4b37540f79b8dd8350b;hb=e57c4de4148d43e7635e09adcde4e56585aea303;hpb=e01e086d96f3c0f04761d269e6a34ba0b6014a56 diff --git a/client/src/store.js b/client/src/store.js index c98657ef..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 } )