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

小程序文档 - 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