From 305f26ccefffe52b3fb65995e8caf437f1a92057 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 9 Nov 2022 10:53:41 -0800 Subject: settings fixes --- src/lib/socket.js | 2 +- src/lib/utils.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/socket.js b/src/lib/socket.js index 9b4a8dce..8d84073c 100644 --- a/src/lib/socket.js +++ b/src/lib/socket.js @@ -36,7 +36,7 @@ export const messages = (data) => ({ async payment() { let { amount, invoice } = data; - if (invoice) invalidate("app:invoice"); + if (invoice) invalidate('app:invoice'); if (get(user)?.account_id !== data.account_id) return; let payments = get(txns); diff --git a/src/lib/utils.js b/src/lib/utils.js index 7e0b8e4f..c3960487 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -37,7 +37,10 @@ export const get = (url, headers = {}) => export const post = (url, body, headers) => { headers = { ...headers, 'content-type': 'application/json', accept: 'application/json' }; return fetch(base + url, { method: 'POST', body: JSON.stringify(body), headers }) - .then((r) => r.text()) + .then(async (r) => { + if (r.ok) return r.text(); + throw new Error(await r.text()); + }) .then((body) => { try { body = JSON.parse(body); -- cgit v1.2.3