【发布时间】:2021-01-20 18:21:25
【问题描述】:
这是我每次调用调用 https 可调用云函数的 manageSubscription() 时遇到的错误:
core.js:4081 ERROR Error: internal
at new HttpsErrorImpl (index.cjs.js:60)
at _errorForResponse (index.cjs.js:155)
at Service.<anonymous> (index.cjs.js:560)
at step (tslib.es6.js:100)
at Object.next (tslib.es6.js:81)
at fulfilled (tslib.es6.js:71)
at ZoneDelegate.invoke (zone-evergreen.js:364)
at Object.onInvoke (core.js:27149)
at ZoneDelegate.invoke (zone-evergreen.js:363)
at Zone.run (zone-evergreen.js:123)
使用:
"@angular/core": "^10.0.4",
"@angular/fire": "^6.0.3",
这是我的应用模块:
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
AngularFireModule.initializeApp(environment.firebaseConfig),
AngularFireFunctionsModule,
SharedComponentsModule,
AppRoutingModule
],
providers: [
{ provide: ORIGIN, useValue: 'http://localhost:5001' }
],
bootstrap: [AppComponent]
})
我正在我的服务中调用 https 可调用云函数:
添加依赖:
constructor(private firebaseFunctions: AngularFireFunctions) {}
这是方法:
public manageSubscription(){
this.firebaseFunctions.useFunctionsEmulator('http://localhost:5001');
const functionRef = this.firebaseFunctions.httpsCallable('testFunction');
functionRef({ returnUrl: 'window.location.origin' })
.subscribe(response => {
console.log(response);
});
}
这是云功能:
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp();
exports.testFunction = functions.https.onCall((data, context) => {
console.log('reached');
return { date: true };
});
我在云函数日志或 chrome 开发控制台的“网络”选项卡中看不到对该函数的调用。我做错了什么?
我尝试了云功能模拟器和实时应用程序。还是没有运气!
自过去 3 天以来,我一直在尝试调试此问题,并且已经失去了一些头发和体重:/
【问题讨论】:
标签: angular firebase google-cloud-functions angularfire