Resolução dos exercícios propostos.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

33 lines
833 B

const endPoint ="http://jailton.bootcamp.dev.netuno.org:20190/services";
document.querySelector('#btnSub').addEventListener('click', e => {
e.preventDefault();
const nome = document.querySelector('#inputNome').value;
const estado = document.querySelector('#inputEstado').value;
const area = document.querySelector('#inputArea').value;
const park = {nome:nome,estado:estado,area:Number(area)};
newParque(park);
})
async function newParque(park) {
const config = {
method:'POST',
body:JSON.stringify(park),
headers: {
"Content-type":"application/json",
}
}
try {
await fetch(`${endPoint}/parque`,config).then((res)=>res.json()).catch((err)=>err);
alert("Parque cadastrado com sucesso!");
} catch (error) {
alert("Erro ao cadastrar parke, erro: "+error.message);
}
}