I trying call an external API, who return an JSON with data who I need complete my form.
I trying do this with this code:
methods: {
verificarCnpj (newValue) {
if (newValue !== 0 && newValue.length === 14) {
console.log('não é vazio e tamanho tem 14')
this.$http.get(`https://www.receitaws.com.br/v1/cnpj/${newValue}`)
.then(response => {
return response.body
})
.catch((error) => {
console.log(error)
})
}
},
.........
Where newValue
is the return on param do pass data to the API.
Example of result of: https://www.receitaws.com.br/v1/cnpj/07623088000147
But I have this return in my console:
Access to XMLHttpRequest at 'https://www.receitaws.com.br/v1/cnpj/07623088000147' from origin 'http://localhost:8071' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
This is the capture of the console errors:
How I Can resolve this?
Thanks, All!