从请求响应节点 .js 中的异步函数返回值

Returning value from async function in request response node.js

提问人:samuel 提问时间:11/8/2023 最后编辑:samuel 更新时间:11/8/2023 访问量:27

问:

当登录函数转到请求响应的顶部时,

它可以正常工作,但是当它转到请求响应时,

这是行不通的。

Parse.Cloud.define("login", async (request) => {

  const { token,username , password } = request.params;

  //when function login is here works fine
 // return  await login(username,password).catch(console.log)


  await Parse.Cloud.httpRequest({
  method: 'POST',
  url: 'https://www.google.com/recaptcha/api/siteverify',
  body: {
    secret: '6Lf2ofMoAAAAANkKsBoFv-1fQasd2meXMxH46PD-Z2Vz',
    response: token
  }


}).then(async function(httpResponse) {

      //but here not working
  return  await login(username,password).catch(console.log)

}, function(httpResponse) {

  console.error('Request failed with response code ' + httpResponse.status);

});

});


'异步函数登录(用户名,密码) {

let user =await Parse.User.logIn(用户名,密码); let userSession=await user.getSessionToken();

console.log(await userSession); 返回 await userSession;

} `

有人有解决方案吗?谢谢

JavaScript 节点.js 异步 async-await

评论

0赞 Community 11/9/2023
请澄清您的具体问题或提供其他详细信息以准确说明您的需求。正如目前所写的那样,很难确切地说出你在问什么。

答: 暂无答案