-2

I'm using the Coinbase Pro official Node.js client library.

How do I access the response object after making a request using promises?

My use case: I'm calling authedClient.getFills() and want to use response.headers['cb-after'] in my next request to get the next page of data. Ultimately, I'm trying to make a function called getAllFills that would get all the pages of fills (one after the other) for a specific product ID.

ma11hew28
  • 121,420
  • 116
  • 450
  • 651
  • Have you tried the syntax of https://github.com/coinbase/gdax-node#using-promises? In the example `products` is the response from the API – Rashomon Sep 02 '18 at 21:44
  • No, I hadn't tried it because I figured `products` was `data`. I just tried, and yes, `products` is `data` (the response body). I need the `response` object, which has the response headers, status code, etc. – ma11hew28 Sep 02 '18 at 22:35
  • 1
    if you want help with *your* code, shouldn't you put that in the question? – Jaromanda X Sep 02 '18 at 22:39
  • @JaromandaX I want help with their API, not my code. – ma11hew28 Sep 02 '18 at 23:05
  • *their API* is documented, as per your links ... how you are using *their API* is anyones guess - but if you think your question is somehow on topic, I guess with 53k reputation you'll probably get away with such a poor quality question – Jaromanda X Sep 02 '18 at 23:11
  • @JaromandaX their documentation doesn't answer my question. But, I was able to answer my own question by reading their source code. – ma11hew28 Sep 02 '18 at 23:36

1 Answers1

0

You can't. To access the response object, you must use the callback API.

Their promise API doesn't expose the response object. You can see this if you look at the PublicClient.makeRequestCallback() method in /lib/clients/public.js of the Coinbase Pro Node.js API source code on GitHub.

ma11hew28
  • 121,420
  • 116
  • 450
  • 651