我試圖調用服務器上的異步方法中的條紋API(JavaScript中,使用MeteorJS),像這樣:調用API條紋與等待
selectedPlan = await Stripe.plans.retrieve(stripePlanId);
條紋API調用(使用的NodeJS庫)有一個回調來處理錯誤,但是如果我使用await模式,可以使用什麼語法來捕獲錯誤?
試圖像
[error, selectedPlan] = await Stripe.plans.retrieve(stripePlanId);
,但沒有奏效。
'retrieve'必須返回一個承諾,否則你不能'await'它。如果需要回撥,請首先進行提示。 – Bergi