Lost in callback hell with Node, Express and google Analytics API

I'm a beginner here so I'll try to expose my issue the best way I can. I'm trying to call the Google Analytics API on the server-side to show some data on the client-side with react and d3. Here is my script to call the GA api :

And then expecting it to be available here in queryData(analytics) in your export.

What you can do instead is resolve your authorize call in a promise (since there will be a race condition when it first initializes, so you can wrap it in a promise and wait for it to resolve before being able to call queryData). Something like this: