小程序云函数异步返回结果 简写


小程序文档 - https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/functions/async.html

1 // index.js
2 exports.main = async (event, context) => {
3   return new Promise((resolve, reject) => {
4     // 在 3 秒后返回结果给调用方(小程序 / 其他云函数)
5     setTimeout(() => {
6       resolve(event.a + event.b)
7     }, 3000)
8   })
9 }

 

简写 - https://www.jianshu.com/p/944df1ad6f63

1 // index.js
2 exports.main = async (event, context) => new Promise((resolve, reject) => {
3     // 在 3 秒后返回结果给调用方(小程序 / 其他云函数)
4     setTimeout(() => {
5         resolve(event.a + event.b)
6     }, 3000)
7 }

 

https://github.com/TencentCloudBase/Cloudbase-Examples/blob/master/web/tcb-demo-files/cloudfunctions/functions/upload/index.js


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM