Adam Muller Adam Muller - 11 months ago 59
Node.js Question

console.log in callback instead of a function

I'm using the API, and for each methods, in the examples, they use console.log as callback.

I don't understant how it works, I tried to get it in a function, but i get 'null'.

If I use console.log, it writes null first, then the object.

it tried :

block_io.get_new_address({}, (data) => {

Here is the API :

Someone can explain me how to deal with it ? Thanks

Answer Source

open the console in your browser, and type typeof console.log you will get "function", it's like any function with parentheses so imagine with

> block_io.get_new_address({'label': 'shibe1'}, ``function here``);

will be

> block_io.get_new_address({'label': 'shibe1'}, console.log);

and all of this is just an example of how to use it, check this out :

// please use the Dogecoin Testnet API key here
var client = new BlockIo({
  version: 2

client.get_new_address({label: 'testDest'}, function (error, data) {
  if (error) return console.log("Error occured:", error.message);