Authentication external sites

0

I'm using JWT to do access authentication. When I try to get a GET request from outside my system, it displays this message:

codesnippetwhereImaketherequest(js):

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

IuseReactandPHPwiththeSlimFramework

NOTE:Ifyouwanttotestthelink,justputanyzipcodeinsteadofthevariableinthecode(eg link

    
asked by anonymous 14.06.2018 / 14:36

1 answer

0

You are passing by default a header that 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>
    
14.06.2018 / 15:37