条带检索客户方法返回客户还是将其传递给回调?

时间:2019-05-11 06:33:22

标签: async-await stripe-payments

我下面的代码在回调中检索客户,但从await调用中检索不到。其他方法似乎会从await调用传回一个对象,所以不应该检索?

customer = await stripe.customers.retrieve(
          stripeCustomer,
          function (err, customer) {
            // asynchronously called
            sails.log('checkout retreive err ', err);
            if (customer) sails.log('checkout retreived customer.id ', customer.id);
          }
        );
sails.log("checkout customer id after retreive ", customer ? customer.id : 0);

日志消息:

debug: checkout customer id after retreive  0
debug: checkout retreive err  null
debug: checkout retreived customer.id  cus_abc...xyz 

条纹文档说该方法返回对象。 谢谢

PS:该代码的目的是检查给定客户是否已经有一个活动帐户。

0 个答案:

没有答案