58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
/**
|
|
* Script de teste para create-user
|
|
* Mostra request e response detalhados
|
|
*/
|
|
|
|
const testCreateUser = async () => {
|
|
const requestData = {
|
|
email: "guilhermesilvagomes1020@gmail.com",
|
|
full_name: "Guilherme Silva Gomes Teste",
|
|
role: "paciente",
|
|
create_patient_record: true,
|
|
cpf: "12345678901",
|
|
phone_mobile: "11999999999",
|
|
};
|
|
|
|
console.log("=== REQUEST ===");
|
|
console.log("URL:", "http://localhost:8888/.netlify/functions/create-user");
|
|
console.log("Method:", "POST");
|
|
console.log("Headers:", {
|
|
"Content-Type": "application/json",
|
|
});
|
|
console.log("Body:", JSON.stringify(requestData, null, 2));
|
|
console.log("\n");
|
|
|
|
try {
|
|
const response = await fetch(
|
|
"http://localhost:8888/.netlify/functions/create-user",
|
|
{
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify(requestData),
|
|
}
|
|
);
|
|
|
|
console.log("=== RESPONSE ===");
|
|
console.log("Status:", response.status, response.statusText);
|
|
console.log("Headers:", Object.fromEntries(response.headers.entries()));
|
|
|
|
const data = await response.json();
|
|
console.log("Body:", JSON.stringify(data, null, 2));
|
|
|
|
if (!response.ok) {
|
|
console.log(
|
|
"\n❌ ERRO:",
|
|
data.error || data.message || "Erro desconhecido"
|
|
);
|
|
} else {
|
|
console.log("\n✅ SUCESSO!");
|
|
}
|
|
} catch (error) {
|
|
console.error("\n❌ ERRO NA REQUISIÇÃO:", error.message);
|
|
}
|
|
};
|
|
|
|
testCreateUser();
|