-1
Sorry, guys, I’m very new to programming and I’m doing a project for a college. I managed to connect the api, I can bring the object from there, but I can’t render this data that is returned, I’ve tried a lot and it didn’t work. Can someone give me a light? Tomorrow I have to present it and do not know how to do. the code is so and lost in what to do ...
const Empresa = () => { const [itens, setItens] = useState([]) async function buscar(event) {
event.preventDefault();
const cpf = document.getElementById('cpf').value
try {
if (cpf !== null) {
if (cpf !== '') {
const response = await api.post('/pacientes/atestados',
{
cpf
});
setItens(response.data);
if (response.data !== null) {
setItens(response);
console.log(itens)
}
if (response.data == '') {
console.log(response.data)
alert('CPF não cadastrado')
}
}
else {
alert('Preencha todos os campos')
}
}
}
catch (error) {
alert(error);
}
} return (
<>
<Header />
<h1>Bem vindo Empresa!</h1>
<h2>Pesquisar Atestado</h2>
<form >
<div className="grupo de formulários">
<label htmlFor="cpf"> CPF </ label>
<input name="cpf" className="controle de formulário"
id="cpf" placeholder="Digite o cpf do funcionário"
/>
</ div>
<button type="submit"
className="form-contact-button" onClick={buscar}> Buscar atestado </ button>
</ form>
{/* <button id="form-contact-button2" onClick={sair}>SAIR</button> */}
</>