cadastro.html:1
Access to fetch at 'https://viacep.com.br/ws/02334090/json/' from origin 'http://127.0.0.1:5500' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
GET https://viacep.com.br/ws/02334090/json/ net::ERR_FAILED
ele diz que tem algum erro noo CORS o projeto ja ta rodando no Live server
function RecuperarCEP(input) {
const cep = input.value.replace(/\D/g, '')
const url = `http://viacep.com.br/ws/${cep}/json/`
const options = {
method: 'GET',
mode: 'cors',
headers: {
'content-type': 'application/json;charset=utf-8'
}
}
if(!input.validity.patternMismatch && !input.validity.valueMissing) {
fetch(url,options).then(
response => response.json()
).then(
data => {
if(data.erro) {
input.setCustomValidity('Não foi possível buscar o CEP.')
return
}
input.setCustomValidity('')
preencheCamposComCEP(data)
return
}
)
}
}