From cd9e850f9e15e890727026942d646d59f526fe4e Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 26 Jul 2022 23:37:18 -0700 Subject: fix invoice endpoint --- src/lib/socket.js | 1 + src/lib/utils.js | 2 +- src/routes/invoice.js | 15 +++------------ 3 files changed, 5 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/lib/socket.js b/src/lib/socket.js index 9d0c472e..90238c23 100644 --- a/src/lib/socket.js +++ b/src/lib/socket.js @@ -24,6 +24,7 @@ export const messages = (data) => ({ connected: auth, login() { + console.log("OY", data) user.set(data); } }); diff --git a/src/lib/utils.js b/src/lib/utils.js index 5b1bba7f..c17b0a98 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -11,4 +11,4 @@ export const post = (url, body) => method: 'POST', body: JSON.stringify(body), headers: { accept: 'application/json', 'content-type': 'application/json' } - }).then((r) => r.json); + }).then((r) => r.json()); diff --git a/src/routes/invoice.js b/src/routes/invoice.js index 147da2b7..4b3327f6 100644 --- a/src/routes/invoice.js +++ b/src/routes/invoice.js @@ -1,21 +1,12 @@ -import got from 'got'; +import { post } from '$lib/utils'; import { invoiceAmount } from '$lib/store'; const username = 'bob', network = 'lightning'; export async function GET({ params }) { - let text = await got - .post('http://localhost:3119/lightning/invoice', { - json: { amount: invoiceAmount } - }) - .text(); - - await got - .post('http://localhost:3119/invoice', { - json: { invoice: { text, network }, user: { username } } - }) - .json(); + let { text } = await post('/lightning/invoice', { amount: invoiceAmount }); + await post('/invoice', { invoice: { text, network }, user: { username } }); return { body: { text } }; } -- cgit v1.2.3