| | |
| | | method: 'POST', |
| | | body: formData |
| | | }); |
| | | const result = await response.json(); |
| | | const body = await response.text(); |
| | | let result; |
| | | try { |
| | | result = JSON.parse(body); |
| | | } catch (err) { |
| | | throw new Error(`Сервер вернул не JSON (HTTP ${response.status}): ${body.slice(0, 240)}`); |
| | | } |
| | | |
| | | msgEl.classList.remove('hidden'); |
| | | if (result.ok) { |
| | |
| | | headers: {'Content-Type': 'application/x-www-form-urlencoded'}, |
| | | body: new URLSearchParams({action_id: actionId, chat_id: chatId}) |
| | | }); |
| | | const result = await response.json(); |
| | | const body = await response.text(); |
| | | let result; |
| | | try { |
| | | result = JSON.parse(body); |
| | | } catch (err) { |
| | | throw new Error(`Сервер вернул не JSON (HTTP ${response.status}): ${body.slice(0, 240)}`); |
| | | } |
| | | |
| | | if (result.ok) { |
| | | btn.closest('.flex').remove(); |