From ff01ba517c019133829b4bd3f3e51ed7d7831e1b Mon Sep 17 00:00:00 2001 From: Shangaman Date: Fri, 4 Nov 2022 23:00:16 +0100 Subject: [PATCH] test if I can get the balance --- app.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 9810e6a..7e92c43 100644 --- a/app.js +++ b/app.js @@ -19,9 +19,34 @@ fetch('http://127.0.0.1:51473/', { }).then(res => res.text()) .then(text => console.log(text)); */ + +(async () => { + try { + await fetch(url, {signal}); + } catch (error) { + if (error.name === 'AbortError') { + console.log('request was aborted'); + } + } +})(); + async function getgoogle(){ - let output= await fetch('https://google.com') - return await output.text() + try{ + let output= await fetch('http://127.0.0.1:51473/', { + method: 'POST', + headers: { + 'content-type': 'text/plain;', + 'Authorization': 'Basic ' + encodeBase64('masternode_test:p') + }, + body: '{"jsonrpc": "1.0", "id":"curltest", "method": "getbalance", "params": [] }'}); + return output.text() + }catch(error){ + if (error.name === 'AbortError') { + return "request was aborted'"; + }else{ + return "non u sac"; + } + } }