Question: I'm trying to work out the Coinbase Pro node.js API.

When running this:

```
const buyParams = {
  price: '100.00', // USD
  size: '1', // BTC
  product_id: 'BTC-USD',
};
authedClient.buy(buyParams, callback);

```

I have the following error `callback is not defined` 

So I'm trying to understand how does callback work exactly. 

What is the callback here exactly? If I understand well I need to define the callback which is a function but what would be the purpose of this function? I this because I need to wait for the answer from `authedClient` method? Or this something else?

Answer: 
`.buy` method will call provided callback when it finishes.  

You probably want to do something depending on the result.  

That's why you need that callback.
You should read API carefully, but in this situation the second parameter of **.buy** is a function you passed to it to execute after .buy runs.

```
const buyParams = {
price: '100.00', // USD
size: '1', // BTC
product_id: 'BTC-USD',
};
const cb = ()=> {
 console.log('Buy finished!');
}
authedClient.buy(buyParams, cb);

```

you should read API document for parameters of cb. but in simple way it's some thing like up code! and after buy finished cb called and log the 'Buy Finished';

feel free to ask more questions.