【问题标题】:Unknown Syntax Error when implementing Cloud Functions in the new AngularFire 7 (Firebase 9)在新的 AngularFire 7 (Firebase 9) 中实现云函数时出现未知语法错误
【发布时间】:2021-12-07 11:45:51
【问题描述】:

在 app.module.ts 中

import { provideFunctions, getFunctions } from '@angular/fire/functions';

@NgModule({
  imports: [
    ...
    provideFirebaseApp(() => initializeApp(environment.firebase)),
    provideFunctions(() => getFunctions()),
  ],

在我的 app.component 中

export class AppComponent {
  constructor(private fns: Functions) {}

  hello() {
    httpsCallable(
      this.fns,
      'test'
    )('hello world').then(() => console.log('complete'));
  }
}

这段代码运行得很好,但是为什么会出现这个语法错误

【问题讨论】:

    标签: javascript angular firebase google-cloud-functions angularfire2


    【解决方案1】:

    我不确定,但不应该是这样

    import { AngularFireFunctions as Functions } from '@angular/fire/compat/functions';
    

    改为?

    基于functions docs

    所以,它可以用作this.fns.httpsCallable('test')

    【讨论】:

    • 您共享的文档未针对 AngularFire7 更新...对于 firebase 9+,这是实现它的方法doc
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-07
    • 2017-10-17
    • 2020-02-03
    • 1970-01-01
    • 2020-10-06
    相关资源
    最近更新 更多