Javascript TypeError:res.send(…)。then不是函数

Javascript TypeError:res.send(…)。then不是函数,javascript,ios,firebase,google-cloud-functions,Javascript,Ios,Firebase,Google Cloud Functions,在我的index.js中,我有一个函数,其结尾如下: 返回res.send(response).then(saveProductID(uid,product.id)); 在Firebase控制台中,其显示: TypeError:res.send(…)。then不是函数 完整代码示例: exports.createConnectAccount=functions.https.onRequest(异步(req,res)=>{ var数据=req.body console.log(data,“我在文

在我的
index.js
中,我有一个函数,其结尾如下:

返回res.send(response).then(saveProductID(uid,product.id));
在Firebase控制台中,其显示:

TypeError:res.send(…)。then不是函数

完整代码示例:

exports.createConnectAccount=functions.https.onRequest(异步(req,res)=>{
var数据=req.body

console.log(data,“我在文档中看不到任何内容或暗示Response.send将返回承诺,也看不到任何假定它返回承诺的代码示例。它不是一个异步函数,在常见的成功案例中,它似乎会返回
(甚至没有文档记录)

我想知道您过去是否在这方面“运气好”,因为您一直在使用
。then()
不是在
res.send
的特定返回值上,而是在返回它的异步函数的返回值上:

async foo(res) {
  return res.send();
}

foo().then(a => console.log('this will work.'));
因为JS运行时会自动将
async
函数的返回值包装在一个Promise中,所以在使用此模式时,您总是会得到一个thenable对象

我不确定您的代码片段中的具体内容,但我相信以下内容将具有您想要的行为:

res.send(response)
return createStripe_Accounts(uid, account);