[英]JavaScript - return function value outside of another function
我正在尝试从下面的代码中获取返回的响应。 下面是一个云函数(Parse Server),当前不返回任何东西,唯一返回的值在.then(verification => {})
Parse.Cloud.define("sendVerificationCode", async (request) => {
await client.verify.services('VAc357322eb2d70fd893237ba44d42333')
.verifications
.create({
to: request.params.phoneNumber,
channel: 'sms',
}).then(verification => {
//The value here is readable
return verification;
}, error => {
return error;
});
// Can I return `verification` value here too?
});
现在的问题是,我可以返回verification
低于价值await
?
PS我使用客户端来获取返回的值。
Parse.Cloud.define("sendVerificationCode", async (request) => {
return await client.verify.services('VAc357322eb2d70fd893237ba44d42333')
.verifications
.create({
to: request.params.phoneNumber,
channel: 'sms',
});
});
这将在您要求的地方返回验证,但由于整个函数都作为回调传递,因此我看不到该值应返回到哪里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.