Fix: Update WhatsApp API request

Update the API endpoint and apikey for the WhatsApp instance creation request.
This commit is contained in:
gpt-engineer-app[bot] 2025-05-19 13:22:42 +00:00
parent 991964846a
commit 70dd4fc790

View File

@ -49,10 +49,9 @@ const WhatsApp = () => {
setLoading(true); setLoading(true);
try { try {
// This is a placeholder for the actual API call to Evolution API // Using the provided URL and API key for Evolution API
// In a real implementation, you would replace {server-url} and {sua-api-key} with actual values const serverUrl = "evolutionapi2.innova1001.com.br";
const serverUrl = "evolution-api-server-url"; const apiKey = "beeb77fbd7f48f91db2cd539a573c130";
const apiKey = "your-evolution-api-key";
const response = await fetch(`https://${serverUrl}/instance/create`, { const response = await fetch(`https://${serverUrl}/instance/create`, {
method: 'POST', method: 'POST',
@ -70,31 +69,11 @@ const WhatsApp = () => {
const data = await response.json(); const data = await response.json();
// In a development environment, simulate a successful response
if (!response.ok) { if (!response.ok) {
// For demonstration purposes, show a simulated success response throw new Error(data.message || 'Erro ao criar instância');
console.log("Simulating successful API response in development environment"); }
const simulatedResponse = {
instanceId: `inst_${Date.now()}`,
status: "created",
message: "Instance created successfully"
};
setInstance({ // Handle successful response
instanceName,
instanceId: simulatedResponse.instanceId,
status: simulatedResponse.status
});
// Save the instance ID for later use
localStorage.setItem('whatsappInstanceId', simulatedResponse.instanceId);
toast({
title: "Sucesso!",
description: "Instância do WhatsApp criada com sucesso!"
});
} else {
// Handle actual API response
setInstance({ setInstance({
instanceName, instanceName,
instanceId: data.instanceId, instanceId: data.instanceId,
@ -109,7 +88,6 @@ const WhatsApp = () => {
title: "Sucesso!", title: "Sucesso!",
description: "Instância do WhatsApp criada com sucesso!" description: "Instância do WhatsApp criada com sucesso!"
}); });
}
} catch (error) { } catch (error) {
console.error("Error creating WhatsApp instance:", error); console.error("Error creating WhatsApp instance:", error);
toast({ toast({