completed 2.12
This commit is contained in:
parent
70992d6cb0
commit
dfeec4d353
3 changed files with 30 additions and 11 deletions
|
|
@ -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("");
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue