Authentication external websites

Asked

Viewed 93 times

0

I am using JWT to authenticate access. When I try a GET request from outside my system, it displays this message:

inserir a descrição da imagem aqui

snippet of the code where I make the request (js):

[...]
var cep = this.soNumero(this.state.cep);
var cepUrl = 'https://viacep.com.br/ws/' + cep + '/json/';
axios.get(cepUrl).then(res => { 
[...]

I use React and PHP with the Slim Framework

NOTE: If you want to test the link, just put any ZIP code in place of the variable in the code (Ex.:https://viacep.com.br/ws/37701140/json/)

1 answer

1


You are passing by default a header that the server-side (Viacep) does not accept, which is X-Access. Clear your default header before the request:

axios.defaults.headers.common = {}
axios.get('https://viacep.com.br/ws/01311200/json/')
      .then(res => console.log(res.data))
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.