I have run the monero-wallet-rpc using the below command:
./monero-wallet-rpc --rpc-bind-port 8080--rpc-bind-ip 127.0.0.1 --prompt-for-password --wallet-file sample-wallet --rpc-login walletuser:user1234 --confirm-external-bind
When I do the below curl command, it's working fine.
curl -X POST http://127.0.0.1:8080/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_address","params":{"account_index":0,"address_index":[0,1,4]}}' -H 'Content-Type: application/json' -u walletuser:user1234 --digest
But when I try to call the RPC from the below javascript code, I am getting 401 Unauthorized
error.
var digestRequest = require('request-digest')('walletuser', 'user1234');
digestRequest.requestAsync({
host: 'http://127.0.0.1',
path: '/json_rpc',
port: 8080,
method: 'POST',
json: true,
body: {"jsonrpc":"2.0","id":"0","method":"get_address","params":{"account_index":0,"address_index":[0,1,4]}},
headers: { "Content-Type": "application/json" }
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
Can any one please help me to resolve this issue. Thanks in advance.