File size: 2,370 Bytes
a964b2a
42c7dd6
a964b2a
 
 
42c7dd6
e172814
 
 
 
 
db357cd
e172814
 
 
 
 
 
 
db357cd
e172814
 
 
 
 
 
 
 
 
 
 
 
 
 
689d9b8
e172814
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a964b2a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Получение информации о группе</title>



</head>
<body>
    <h1>Получение списка параметров группы</h1>
    <form id="groupForm">
        <label for="groupId">Идентификатор группы:</label>
        <input type="text" id="groupId" name="groupId" required>
        <br>
        <label for="apiToken">API Токен:</label>
        <input type="text" id="apiToken" name="apiToken" required>
        <br>
        <button type="submit">Получить список параметров группы</button>
    </form>
    <div id="result"></div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const groupForm = document.getElementById('groupForm');
            const resultDiv = document.getElementById('result');

            groupForm.addEventListener('submit', function(event) {
                event.preventDefault();

                const groupId = document.getElementById('groupId').value;
                const apiToken = document.getElementById('apiToken').value;

                const url = `https://test-sj-crm-psy-vk.hf.space/api/group/${groupId}/parameters?apiToken=${apiToken}`;

                fetch(url, {
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json'
                    }
                })
                .then(response => {
                    if (!response.ok) {
                        throw new Error('Network response was not ok ' + response.statusText);
                    }
                    return response.json();
                })
                .then(data => {
                    if (data.error) {
                        resultDiv.innerHTML = `<p style="color: red;">Ошибка: ${data.error}</p>`;
                    } else {
                        resultDiv.innerHTML = `<pre>${JSON.stringify(data, null, 2)}</pre>`;
                    }
                })
                .catch(error => {
                    resultDiv.innerHTML = `<p style="color: red;">Ошибка: ${error.message}</p>`;
                });
            });
        });
    </script>
</body>
</html>