云函数的传值失败的问题?

小程序 文章 2020-08-03 09:41 579 0 全屏看文

AI助手支持GPT4.0

云函数的传值失败的问题?

我想通过云函数获取用户的openid,再把值传给全局变量globalData中,可是输出的确实空的。

结果如下:

如果把console.log("id:"app.globalData.userID)放进云函数中的话是可以得出结果的,放外面却不行,这是为什么?是云函数无法传值到外部吗?

I want to get the user's openid through the cloud function, and then pass the value to the global variable GlobalData, but the output is really empty. The results are as follows: if the console.log ("id:" app.globalData.userID )Put into the cloud function, you can get the result, but you can't put it outside. Why? Is the cloud function unable to transfer values to the outside?

回答:

Distance:

异步问题……

胖丫么胖:

= =没请求完 先打印log,不是空是啥。

Admin²⁰²⁰:

console.log("id:"app.globalData.userID)放到最内圈的{}里面就行了

-EOF-

AI助手支持GPT4.0