const config = 'dev'; const backend_api = { 'prod': '/zetikettes/srv/', 'dev': 'http://scrawny.local:3000', }[config]; let token = localStorage.getItem('token'); async function getBandz() { const uri = `${backend_api}/bandz`; const res = await $.ajax(uri, {headers: {Authorization: `Bearer ${token}`}}); // if (res.statusCode !== 200) { // throw res; // } return res.bandz; } async function wrapAChikin(req) { const uri = `${backend_api}/wrap`; const res = await $.ajax(uri, { type: 'POST', contentType: 'application/json', data: JSON.stringify(req), headers: {Authorization: `Bearer ${token}`}, }); return res.chikinId; } async function authenticate(password) { const uri = `${backend_api}/toktok`; const res = await $.ajax(uri, { type: 'POST', contentType: 'application/json', data: JSON.stringify({password}), }); return res; } function printLabel(chikinId) { const uri = `${backend_api}/print`; $.ajax(uri, { type: 'POST', contentType: 'application/json', data: JSON.stringify({chikinId}), headers: {Authorization: `Bearer ${token}`}, }); } $(document).ready(() => { const appbody = $("#appbody"); const bandSelect = $('