UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) 776 B
import{KIOSK_STATS_ID_STORAGE_KEY as a}from"./SetKiosk/constants";const r={"Content-Type":"application/json"};function n(o,s){const e=new URL(o,s);return e.searchParams.set("expoKey",window.__efpEvent),e.toString()}export async function createKiosk(o,s){try{const e=await fetch(n("/api/kiosks",s),{method:"POST",headers:r,body:JSON.stringify(o)});return e.ok?(await e.json()).key??null:(console.error("createKiosk",e.status,e.statusText),null)}catch(e){return console.error("createKiosk",e),null}}export async function updateKiosk(o,s){const e=localStorage.getItem(a);if(e)try{const t=await fetch(n("/api/kiosks",s),{method:"POST",headers:r,body:JSON.stringify({...o,key:e})});t.ok||console.error("updateKiosk",t.status,t.statusText)}catch(t){console.error("updateKiosk",t)}}