-1

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?

wowkin2
  • 5,895
  • 5
  • 23
  • 66
alibag90
  • 17
  • 4
  • 8
  • 1
    Possible duplicate of [parsing JSON in nodejs](https://stackoverflow.com/questions/14208707/parsing-json-in-nodejs) – Farsheel Aug 29 '18 at 04:12

1 Answers1

0

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);
})
Valle
  • 36
  • 4