У меня есть этот код, чтобы проверить, взято ли письмо или нет, оно работает, просто выдает ошибку в журналах облачных функций. Вот код swift:
let functions = Functions.functions()
functions.httpsCallable("uniqueEmail").call(email) { (result, error) in
if let error = error as NSError? {
if error.domain == FunctionsErrorDomain {
let code = FunctionsErrorCode(rawValue: error.code)
let message = error.localizedDescription
let details = error.userInfo[FunctionsErrorDetailsKey]
}
// ...
}
if let text = (result?.data as? [String: Any])?["text"] as? String {
//self.resultField.text = text
}
}
Вот код функции облака:
import * as functions from 'firebase-functions'
import * as admin from 'firebase-admin'
admin.initializeApp()
exports.uniqueEmail = functions.https.onCall((req, res) => {
const email = req.query.email;
if (!email) {
throw new functions.https.HttpsError('invalid-argument', 'Missing email parameter');
}
admin.auth().getUserByEmail(email)
.then(function(userRecord) {
// See the UserRecord reference doc for the contents of userRecord.
console.log('Successfully fetched user data:', userRecord.toJSON());
return({taken: true}); // Returns {"taken": "true"} or {"taken": "false"}
})
.catch(function(error) {
console.log('Error fetching user data:', error);
return({taken: false}); // Returns {"taken": "true"} or {"taken": "false"}
});
});
И вот ошибка, которую я получаю в облачных функциях, я не уверен, что оба означают, поэтому кто-то может объяснить мне их оба?
1
Платежный аккаунт не настроен. Внешняя сеть недоступна, и квоты строго ограничены. Настройте платежный аккаунт, чтобы снять эти ограничения
2
Unhandled error TypeError: Cannot read property 'email' of undefined
at exports.uniqueEmail.functions.https.onCall (/user_code/lib/index.js:7:28)
at /user_code/node_modules/firebase-functions/lib/providers/https.js:330:32
at next (native)
at /user_code/node_modules/firebase-functions/lib/providers/https.js:28:71
at __awaiter (/user_code/node_modules/firebase-functions/lib/providers/https.js:24:12)
at func (/user_code/node_modules/firebase-functions/lib/providers/https.js:294:32)
at corsHandler (/user_code/node_modules/firebase-functions/lib/providers/https.js:350:44)
at cors (/user_code/node_modules/firebase-functions/node_modules/cors/lib/index.js:188:7)
at /user_code/node_modules/firebase-functions/node_modules/cors/lib/index.js:224:17
at originCallback (/user_code/node_modules/firebase-functions/node_modules/cors/lib/index.js:214:15)