Я получаю эту ошибку:
[Ошибка: ВНУТРЕННЯЯ]
Это do c говорит : [Ошибка: ВНУТРЕННЯЯ]: Внутренняя ошибка сервера. Обычно это ошибка сервера.
Я попытался вернуть только email
+ password
из функции, и она вернулась, так что это означает, что отправка параметров выполняется правильно, проблема должна быть где-то в admin.auth()
.
Я попытался жестко закодировать адрес электронной почты и пароль в функции и просто вызвать его из RN, но та же ошибка.
Функция Cloud, включая импорт:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
exports.registerNewPatient = functions.region('europe-west3').https.onCall((data, context) => {
if (!data.email) throw "Missing email parameter";
if (!data.password) throw "Missing password parameter";
const email = data.email;
const password = data.password;
return admin.auth().createUser({
email: email,
emailVerified: false,
password: password,
disabled: false
})
.then(function (userRecord) {
return userRecord.uid;
})
.catch(function (error) {
throw new functions.https.HttpsError('Error creating user', error);
});
});
И вот как я звоню из кода RN:
firebase.app().functions('europe-west3').httpsCallable('registerNewPatient')({
email: "bimiiix@hotmail.com",
password: "bbbbbb1"
}).then((onfulfilled, onrejected) => {
if (onfulfilled) {
console.log("OK callback function:", onfulfilled);
} else {
console.log("Error callback function:", onrejected)
}
}).catch(error => { console.log("ERror handled", error)
})