2 lines
690 B
JavaScript
2 lines
690 B
JavaScript
const a="/api";async function t(e,s){const r=await fetch(`${a}${e}`,{headers:{"Content-Type":"application/json"},...s});if(!r.ok){const o=await r.text();throw new Error(`API ${e} failed (${r.status}): ${o}`)}return r.json()}const c={listProducts:()=>t("/catalog/products"),listCustomers:()=>t("/customers"),getCustomer:e=>t(`/customers/${e}`),getBalance:e=>t(`/accounting/customers/${e}/balance`),getLedgerEntries:e=>t(`/customers/${e}/ledger-entries`),createOrder:e=>t("/orders",{method:"POST",body:JSON.stringify(e)}),getCustomerOrders:e=>t(`/customers/${e}/orders`),getLatestGoldPrice:(e=750)=>t(`/pricing/latest?karatPerMille=${e}`),getHomeSlider:()=>t("/home/slider")};export{c as a};
|