0
const publicKey = req.body;
try {
    //connect to daemon
    let daemon = await monerojs.connectToDaemonRpc("http://localhost:28081", "pinkumonero", "1234");
    let height = await daemon.getHeight();
    console.log("Height is:", height);
    
    const response = axios.post("http://localhost:28082",
        publicKey,
        {
            headers: {
                'Content-Type': 'application/json'
            },
        }).then((responseData) => {
            dataFetched = responseData.data;
            console.log("Result of fetching balance", dataFetched);
            res.status(200).json({ Balance: dataFetched });
        })

} catch (err) {
    console.log("Error in fetching balance of XMR", err);
    res.status(500).json({ StatusCode: "0", Message: "Error in XMR balance fetching", error: err.message })
}

})

2
  • Using curl command in the CLI [curl 127.0.0.1:28082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_balance","params":{"account_index":0,"address_indices":[0,1]}}' -H 'Content-Type: application/json'] Feb 8, 2023 at 8:01
  • curl: (1) Received HTTP/0.9 when not allowed ===>This error appears Feb 8, 2023 at 8:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.