它以前可以工作,但是现在我遇到了错误,我试图进行故障排除,但仍然没想到。
所以下面是我的Angular服务代码:
import * as firebase from 'firebase/app'; //the import
//the function
createUser(user){
let createUserFunction = firebase.functions().httpsCallable('createUser')
return createUserFunction(user)
}
这是我从组件中调用服务的方式:
this.authService.createUser(this.user).then(newUser => {
//some other logic
},error=>{
console.log(error)
})
下面是我的nodejs代码:
const functions = require('firebase-functions');
var admin = require('firebase-admin');
var serviceAccount = require('./keys/privatekey.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: 'https://<project_id>.firebaseio.com'
});
exports.createUser = functions.https.onCall((data, context) => {
let newUser = {
emailVerified: false
}
if (data.email && data.password) {
newUser["email"] = data.email
newUser["password"] = data.password
}
else {
return {
code: -1,
msg: "email/password is missing"
}
}
return admin.auth().createUser(newUser).then(userRecord => {
console.log("successfully created new User: ", userRecord.uid, ", by: ", context.auth.uid)
console.log(userRecord)
return userRecord
}).catch(error => {
console.log("Failed to create user: ", error)
throw new functions.https.HttpsError('Failed to create user', error);
})
});
以下是错误:
ERROR TypeError: firebase_app__WEBPACK_IMPORTED_MODULE_5__.functions is not a function
当我调用另一个导出的firebase函数时,有时会低于错误
ERROR Error: Uncaught (in promise): TypeError: firebase_app__WEBPACK_IMPORTED_MODULE_1__.functions is not a function
TypeError: firebase_app__WEBPACK_IMPORTED_MODULE_1__.functions is not a function
如果给定的信息不足以解决问题,请告诉我。我也不知道我需要提供什么信息。