Files
crm.clientright.ru/test_client_side_actions.html

70 lines
2.4 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Тест Client Side Actions</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
.test-section { margin: 20px 0; padding: 15px; border: 1px solid #ddd; }
.result { background: #f5f5f5; padding: 10px; margin: 10px 0; }
button { padding: 10px 20px; margin: 5px; }
</style>
</head>
<body>
<h1>Тест Client Side Actions (n8n webhook)</h1>
<div class="test-section">
<h3>Тест выполнения HTTP запроса к n8n</h3>
<button onclick="testHttpRequest()">Отправить запрос в n8n</button>
<div id="result" class="result"></div>
</div>
<script>
async function testHttpRequest() {
const resultDiv = document.getElementById('result');
resultDiv.innerHTML = 'Отправляю запрос...';
try {
const httpRequest = {
url: 'https://n8n.clientright.pro/webhook/0b20bf1e-7cda-4dc8-899e-a7c3be4096c0',
method: 'POST',
body: {
submittedAt: new Date().toISOString(),
input: 'тест запроса из браузера'
}
};
console.log('Отправляю запрос:', httpRequest);
const response = await fetch(httpRequest.url, {
method: httpRequest.method,
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(httpRequest.body)
});
const result = await response.json();
console.log('Получен ответ:', result);
resultDiv.innerHTML = `
<strong>Успешно!</strong><br>
HTTP Status: ${response.status}<br>
Ответ от n8n: <pre>${JSON.stringify(result, null, 2)}</pre>
`;
} catch (error) {
console.error('Ошибка:', error);
resultDiv.innerHTML = `<strong>Ошибка:</strong> ${error.message}`;
}
}
</script>
</body>
</html>