第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

流星:在Meteor.method中調(diào)用異步函數(shù)并返回結(jié)果

流星:在Meteor.method中調(diào)用異步函數(shù)并返回結(jié)果

開滿天機 2019-10-09 15:50:15
我想在Meteor方法中調(diào)用異步函數(shù),然后將結(jié)果從該函數(shù)返回給Meteor.call。(怎么)可能?Meteor.methods({  my_function: function(arg1, arg2) {    //Call other asynchronous function and return result or throw error  }});
查看完整描述

3 回答

?
江戶川亂折騰

TA貢獻1851條經(jīng)驗 獲得超5個贊

對于這種情況,Meteor現(xiàn)在具有Meteor.wrapAsync()。


這是通過Stripe收費并傳遞回調(diào)函數(shù)的最簡單方法:


var stripe = StripeAPI("key");    

Meteor.methods({


    yourMethod: function(callArg) {


        var charge = Meteor.wrapAsync(stripe.charges.create, stripe.charges);

        charge({

            amount: amount,

            currency: "usd",

            //I passed the stripe token in callArg

            card: callArg.stripeToken,

        }, function(err, charge) {

            if (err && err.type === 'StripeCardError') {

              // The card has been declined

              throw new Meteor.Error("stripe-charge-error", err.message);

            }


            //Insert your 'on success' code here


        });

    }

});

查看完整回答
反對 回復(fù) 2019-10-09
  • 3 回答
  • 0 關(guān)注
  • 495 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號