follow along

This commit is contained in:
counterweight 2025-05-26 00:04:01 +02:00
parent 6691671c86
commit 70992d6cb0
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
2 changed files with 12 additions and 6 deletions

View file

@ -42,9 +42,15 @@ const App = ({ startingNotes = [] }) => {
const note = notes.find((n) => n.id === id);
const changedNote = { ...note, important: !note.important };
noteService.update(id, changedNote).then((response) => {
setNotes(notes.map((note) => (note.id === id ? response.data : note)));
});
noteService
.update(id, changedNote)
.then((response) => {
setNotes(notes.map((note) => (note.id === id ? response.data : note)));
})
.catch((error) => {
alert(`The note '${note.content}' was already deleted from server.`);
setNotes(notes.filter((n) => n.id !== id));
});
};
return (

View file

@ -14,7 +14,7 @@ const update = (id, newObject) => {
};
export default {
getAll: getAll,
create: create,
update: update,
getAll,
create,
update,
};