Saturday 27 May 2017

Can't Parse Data node.js correctly

I have tried to send a post request to an api in node.js yet got the response

{ Error: 'Internal server error' }

I used this code:

var request = require('request');
var config = require("./config.json");


var request = require('request');
request.post({
  url:     'https://api.mymonero.com:8443/get_address_txs',
  json:    {method: "post", address:config.address, viewkey:config.viewkey }
}, function(error, response, body){
  console.log(body);
});

This isn't the server as I can do the exact same thing in python really easily and get the expected response

import requests
address = "*Monero Address*"
viewkey = "*Monero Viewkey*"
data = {"address":address,"view_key":viewkey}
response = requests.post("https://api.mymonero.com:8443/get_address_txs",json=data)
print(response.text)

I'm sorry if i'm being dumb I'm new to node.js

Expected Response:

{
  "total_received": "0",
  "scanned_height": 2586375,
  "scanned_block_height": 1319524,
  "start_height": 2586052,
  "transaction_height": 2586375,
  "blockchain_height": 1319524
}

Thanks :)



via Joss Bird

No comments:

Post a Comment