1
I created a Factory to carry out the operations CRUD in a REST API using the $http service to make a user control.
Factory
//Listar..Recuperar ..Inserir ...Editar..{...}
usuarioService.Excluir = function (id) {
var promise = $http({
method: 'DELETE',
url: API_URL.url + '/api/v1/usuario/' + id
})
.then(function (response) {
return response.data;
},
function (response) {
return alert(response.statusText + ' ' + response.data.errors + ' ' + response.data.message);
});
return promise;
};
Controller
//Listar..Recuperar ..Inserir ...Editar..{...}
vm.Excluir = function Excluir() {
usuarioService.Excluir(vm.id).then(function (result) {
$location.path("/usuario");
})
};
How can I capture the answer in cases of erro
in my controller
?
I’ve been researching there ...a concept called Interceptors I’ll see if I can implement it to make the error handling for the HTTP request methods... I’m still studying about it so I haven’t chosen as response .... but this concept and very interesting I think would even create another question ...
– stringnome