Javascript 为什么Firestore云函数返回错误的请求响应?

Javascript 为什么Firestore云函数返回错误的请求响应?,javascript,firebase,google-cloud-firestore,google-cloud-functions,angularfire2,Javascript,Firebase,Google Cloud Firestore,Google Cloud Functions,Angularfire2,我正在关注firebase的youtube频道上的教程。在尝试调用云函数时,我不断收到firebase服务器发出的“错误请求:无效参数”响应。该函数甚至从未被调用过。我猜测数据结构不正确(参数无效),但不确定原因。有人能解释一下吗 云功能: exports.addAdmin = functions.https.onCall( (data: any, context: any) => { const email = data.email; return grantAdminRole(

我正在关注firebase的youtube频道上的教程。在尝试调用云函数时,我不断收到firebase服务器发出的“错误请求:无效参数”响应。该函数甚至从未被调用过。我猜测
数据
结构不正确(参数无效),但不确定原因。有人能解释一下吗

云功能:

exports.addAdmin = functions.https.onCall( (data: any, context: any) => {
  const email = data.email;
  return grantAdminRole(email).then(() => {
    return{
      result: 'Admin role has been assigned successfully'
    }
  }).catch( err => {
    return{
      error: err
    }
  })
})

async function grantAdminRole(email: string): Promise<void> {
  const user = await admin.auth().getUserByEmail(email);
  if( user.customClaims && user.customClaims.admin === true ) {
    return;
  } else {
    return admin.auth().setCustomUserClaims(user.uid, {
      admin: true
    })
  }
};

您的服务器端实现了,如下所示:

functions.https.onCall
但您的客户机随后尝试将其作为一个函数调用:


虽然可调用函数构建在HTTP函数之上,但不能以相同的方式调用它们。您应该调用callable Cloud函数,或者。

您的服务器端实现如下所示:

functions.https.onCall
但您的客户机随后尝试将其作为一个函数调用:

虽然可调用函数构建在HTTP函数之上,但不能以相同的方式调用它们。您应该调用可调用的云函数,或者

this.http.post(this.endpoint, ...