/
delphin
/
CatRW
Обзор
Документация
Войти
/
delphin
/
CatRW
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
test_api.html
47 строк
2 KB
delphin
start project
02 мар 2026, 09:14
Верифицирован
02 мар 2026, 09:14
4b0ee03
Код
Авторство
О чём код?
<!DOCTYPE html> <html> <head><meta charset="UTF-8"> <title>Тест API</title> <style> body { font-family: Arial; padding: 20px; } pre { background: #f0f0f0; padding: 10px; border: 1px solid #ccc; } </style> </head> <body> <h1>Тестирование API производителей</h1> <button onclick="testGet()">1. GET /api/manufacturers.php</button><br><br> <button onclick="testGetWithId()">2. GET /api/manufacturers.php?id=1</button><br><br> <button onclick="testSearch()">3. GET /api/manufacturers.php?action=search&q=Piko</button><br><br> <h3>Ответ API:</h3> <pre id="response"></pre> <script> async function testGet() { const response = await fetch('/api/manufacturers.php'); const text = await response.text(); document.getElementById('response').textContent = text; try { const json = JSON.parse(text); console.log('JSON успешно распарсен:', json); } catch (e) { console.error('Ошибка парсинга JSON:', e.message); } } async function testGetWithId() { const response = await fetch('/api/manufacturers.php?id=1'); const text = await response.text(); document.getElementById('response').textContent = text; } async function testSearch() { const response = await fetch('/api/manufacturers.php?action=search&q=Piko'); const text = await response.text(); document.getElementById('response').textContent = text; } </script> </body> </html>