0
I’m making a request, which returns me error 401, but I can’t get this number
axios.post(config.urlBase + 'adicionar_empresa', formData)
.then(res => {
if(res.data){
this.refs.sucesso.openSucesso(2000);
this.refs.load.closeLoad();
this.limparCampos();
}else{
this.refs.erro.openErro(3000);
this.refs.load.closeLoad();
}
}).catch(e => {
console.log(e)
});
When I run the code up the console displays this:
i believed that in catch he would bring this information but does not bring, anyone knows how I do? I gave a good search and nothing worked for me.
thank you!
Try giving a console.log error.response.status
– Lucas Brogni
I’ve tried that, it doesn’t work... but thanks anyway!
– Otavio Souza Rocha
That’s too bad. If you don’t have to use Xios take a look at fetch and see if it returns the correct error data...
– Lucas Brogni
The parameter you receive from
catch
is an object, and as I recall (I have not tested)e.response.status
should give you the error code.– Isac
@Isac doesn’t work, I’ve tested it
– Otavio Souza Rocha
@Otaviosouzarocha What results ? And
console.log(e.response)
gives what ?– Isac
@Isac I managed to solve, I will post the result
– Otavio Souza Rocha