Я пытаюсь использовать функцию, которую я сделал. Так что в моем клиенте я делаю это:
const functions = firebase.app().functions("europe-west1");
functions.httpsCallable('getSelf').then(res => {
console.log(res);
//stuff
}).catch(e => {
console.log(e);
switch (e.code) {
//stuff
}
})
и в основном я получаю ошибку, functions.httpsCallable(...).then is not a function
. Я действительно не понимаю, и я не нахожу никакой документации, как сделать вызов функции на клиенте в другой версии.
Это мой сервер
// Gets things like adminlevel, profilepic etc
exports.getSelf = functions.region("europe-west1").https.onCall((data, context) => {
// Checking that the user is authenticated.
if (!context.auth)
// Throwing an HttpsError so that the client gets the error details.
throw new functions.https.HttpsError('unauthorized', 'The function must be called ' +
'while authenticated.');
return db.collection("userInformation").doc(context.auth.uid).then(user => {
if(!user)
new functions.https.HttpsError('not-found', 'The user was not found');
//returns needing values
return {
profilePicture: user.profilePicture,
adminLevel: user.adminLevel,
stripeAccountId: user.stripeAccountId,
stripeCustomerId: user.stripeCustomerId,
type: user.type
}
})
});