O meu codigo está identico ao do professor porem quando faço é para ocorrer a requisição para API, somente é mostrado um erro no console:
cadastro.html:1 Access to fetch at 'https://viacep.com.br/ws/*/json%7D' from origin 'http://192.168.15.8:5500' 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. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
validacao.js:163 GET https://viacep.com.br/ws/*/json%7D net::ERR_FAILED
function recuperarCEP(input) {
const cep = input.value.replace(/\D/g, '');
const url = `https://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 => {
console.log(data)
}
)
}
}