Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142188

Waiting for a callback to finish [duplicate]

$
0
0

I have the following method that I need to call from 'stripe' npm package to create a login link for the user.

stripe = require('stripe)('tok_123');
stripe.accounts.createLoginLink(
  'acct_123',
  function(err, link) {
    // asynchronously called
  };
);

Now this method above is being called inside a google cloud function on HTTP call:

functions.https.onCall(async (data, context) => {
    // create stripe login link

    return {
         'link': <link created from createLoginLink>
    }; 
}); 

I would like to return the link from the callback. I am not sure how to do that, how do I wait until the callback function is called and finished inside the body of onCall?


Viewing all articles
Browse latest Browse all 142188

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>