how to parse some data from server response?

141 Views Asked by At

I'm new to nodejs. I now have a code like this.

var Coinpayments = require('coinpayments');

var cpayment = new Coinpayments({
  key: 'api',
  secret: 'api',
  autoIpn: true
});

var address = cpayment.getCallbackAddress("BTC", function (err, response) {

console.log(response);
})

which answers the bellow response :

{ address: '3Du1WGxRf1bPZXrX1EyhdAYB4g113RnDeY' }

But I need the answer just like this:

'3Du1WGxRf1bPZXrX1EyhdAYB4g113RnDeY'

can anyone help me?

1

There are 1 best solutions below

0
Valle On BEST ANSWER

You'll want to access the value of the address key like this:

var Coinpayments = require('coinpayments');

var cpayment = new Coinpayments({
  key: 'api',
  secret: 'api',
  autoIpn: true
});

var address = cpayment.getCallbackAddress("BTC", function (err, response) {

console.log(response.address);
})