completed 2.12

This commit is contained in:
counterweight 2025-05-26 00:18:12 +02:00
parent 70992d6cb0
commit dfeec4d353
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
3 changed files with 30 additions and 11 deletions

View file

@ -58,8 +58,16 @@ const App = () => {
alert(`${newName} is already in the phonebook.`);
return;
}
setPersons(persons.concat({ name: newName, number: newNumber }));
axios
.post("http://localhost:3001/persons", {
name: newName,
number: newNumber,
id: newName,
})
.then((response) => {
setPersons(persons.concat(response.data));
});
setNewName("");
setNewNumber("");
};