我试图了解如何在if (count > 1)
内返回“多个折扣”以及this.redeemDisc
`if (count > 1) {
//return 'multiple discounts';
return this.redeemDisc(
{
//BusinessId: BusinessId,
discountId: offer.id,
userUuid: userUuid,
code: code,
locationId: locationId
}).then(redeemed => {
return redeemed;
}
)
}`
感谢您的帮助!
答案 0 :(得分:0)
您不能返回字符串和对象,但是可以随消息一起返回对象
return { ...redeemed, message: 'multiple discounts' }
答案 1 :(得分:0)
这将返回一个数组,其中第一个解析是您的字符串,第二个是来自请求的结果。您会同时获得两者。
if (count > 1) {
return Promise.all([Promise.resolve('multiple discounts'), this.redeemDisc(
{
//BusinessId: BusinessId,
discountId: offer.id,
userUuid: userUuid,
code: code,
locationId: locationId
});
)])
}