/
Aparadox
/
Test
Обзор
Документация
Войти
/
Aparadox
/
Test
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
frontend/src/components/AddCountryForm.js
33 строки
812 B
aparadox
Initial commit
27 авг 2025, 17:28
27 авг 2025, 17:28
63efeb0
Код
Авторство
О чём код?
// frontend/src/components/AddCountryForm.js import React, { useState } from 'react'; import axios from 'axios'; const AddCountryForm = () => { const [name, setName] = useState(''); const handleSubmit = (e) => { e.preventDefault(); axios.post('http://localhost:8088/api/countries', { name }) .then(res => { alert('Страна успешно добавлена!'); setName(''); }) .catch(err => console.error(err)); }; return ( <form onSubmit={handleSubmit}> <h3>Добавить страну</h3> <input type="text" value={name} onChange={(e) => setName(e.target.value)} placeholder="Название страны" required /> <button type="submit">Добавить</button> </form> ); }; export default AddCountryForm;