I am using firebase as a Web client for an app to create a login system however when I enter a username & password & press login it say server error.
How do I resolve the server error and what does it mean by server error?
Thank you and help would be appreciatedâș The code I used to create the Web client
var ROOT_URL = "https://exampleapp.firebaseio.com/"; // Change to your Firebase App
var FIREBASE_CREDENTIAL = "yourAppSecret"; // Change to your Firebase App Secret
var firebase = {
register : function (email, password, callback) {
var emailReplace = email.replace(/\./g, ",");
var beginRegister = function () {
var requestObj = { "email" : email, "password" : password };
var requestJSON = JSON.stringify(requestObj);
var wcRegister = new SMF.Net.WebClient({
URL : ROOT_URL + "Users/" + emailReplace + ".json?auth=" + FIREBASE_CREDENTIAL,
httpMethod : "POST",
requestHeaders : ['Content-Type:application/json', 'X-HTTP-Method-Override:PATCH'],
requestBody : requestJSON,
onSyndicationSuccess : function (e) {
alert("Begin register success");
},
onServerError : function (e) {
alert("Begin register error");
}
});
wcRegister.run(true);
};
var isTaken = new SMF.Net.WebClient({
URL : ROOT_URL + "Users/" + emailReplace + ".json?auth=" + FIREBASE_CREDENTIAL,
httpMethod : "GET",
requestHeaders : ["Content-Type:application/json"],
onSyndicationSuccess : function (e) {
alert("Is taken sucess");
var response = JSON.parse(isTaken.responseText);
if (response !== null) {
//Email is taken, do something
} else {
beginRegister(); //Email is not taken, continue
}
}, onServerError : function (e) {
//Server Error, do something
alert("Is taken error");
}
});
isTaken.run();
}
};
I am using smartface app studio.
Server error means that your request to given URL couldn't successfully made. I have tested your code and it worked for me with my own firebase configurations.
If you are using custom certificate file, which located in Assets folder of your project and named 'cacert.pem', maybe that CA don't accept that domain I don't know. You can check error message in onServerError with
This will give more detailed information about error. Also did you test url and body with another HTTP request tool like hurl.it?