1
I’m using Angularjs and I have this method
$scope.login = function (email, usuario, senha) {
$http.post("/Login/login", { email: email, usuario: usuario, senha: senha })
.success(function (data) {
debugger;
if (data == "Empresa nao encontrada.") {
UIkit.modal.alert(data, { labels: { 'Ok': 'OK' } });
return;
}
else if (data == "Usuário ou Senha inválidos.") {
UIkit.modal.alert(data, { labels: { 'Ok': 'OK' } });
return;
}
else {
window.sessionStorage.setItem('acessos', JSON.stringify(data));//coloca os acessos em uma sessão.storage
window.location.href = '#/';
}
})
.error(function (error) {
alert("Erro");
});
};
The Backend is returning "Company not found." this can be seen in the following image
But the code of if (data == "Empresa nao encontrada.") {...}
is not executed, only the code of the else
, because?
I don’t know very well , I’m a beginner , but I believe it’s because the
data
that’s you’re picking up on.success(function (data)
, is equal to the object you are passing on$http.post
, then it can’t be that string"Empresa nao encontrada"
– Rubens Barbosa