小程序雲函數異步返回結果 簡寫


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