1
發生網絡錯誤(例如超時,連接中斷或無法訪問的主機)。使用Firebase API登錄時出現超時錯誤
每當我嘗試登錄時總會發生此錯誤。
我的JS代碼:
firebase.auth().signInWithEmailAndPassword(emailId, password).then(function (userData) {
usersRef.child(userData.uid).once("value", function (userSnap) {
var usersSnap = userSnap.val();
/*
* Record login attempt to firebase
*/
if (userSnap) {
authlogRef.child(userData.uid).once('value', function (userLogSnap) {
userLogSnap = userLogSnap.val();
// Initial login count
var loginCount = userLogSnap && userLogSnap.loginCount || 0;
// timestamp for current login
var timestamp = Date.now();
// log data to update
var data = userLogSnap || {};
//If no timestamps -> First login attempt, so timestamps -> []
if (!data.timestamps) {
data['timestamps'] = []
}
// push current timestamp for current login
data.timestamps.push(timestamp)
// increment login count
data['loginCount'] = loginCount + 1;
// set data to end point
authlogRef
.child(userData.uid)
.set(data)
.then(function() {
callback(null, usersSnap);
})
})
}
}).catch(function (error) {
var errorCode = error.code;
var errorMessage = error.message;
if (errorCode == 'auth/invalid-email') {
var msg = 'Email id is not Valid';
callback(msg);
} else if (errorCode == 'auth/user-disabled') {
var msg = 'User is in disable state';
callback(msg);
} else if (errorCode == 'auth/user-not-found') {
var msg = 'User not found';
callback(msg);
} else if (errorCode == 'auth/wrong-password') {
var msg = 'Invalid Password';
callback(msg);
} else if (errorCode == 'auth/network-request-failed') {
var msg = 'Network Error';
callback(msg);
} else {
callback("error:" + errorMessage);
}
});
})
有時候,我得到超時錯誤。但我不能指出什麼是錯的。
嘿@ankit,你可以檢查網絡控制檯,並提供什麼是超時的細節,因爲這可能發生的原因很多。 – bojeil
@bojeil感謝您的回覆,錯誤越來越多的客戶computer.I沒有任何access.In在我的系統中正常working.Very罕見的情況下,我收到此錯誤 –