From fb9fa30ae9dc6f407ca4c103579bbb42c978809b Mon Sep 17 00:00:00 2001 From: Ibrahim Mkusa Date: Sun, 28 May 2023 19:11:18 -0400 Subject: ex3.19 added skeleton for error handling.[TODO] fail gracefully --- part2/phonebook/src/App.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'part2/phonebook/src') diff --git a/part2/phonebook/src/App.js b/part2/phonebook/src/App.js index fa46962..0de0544 100644 --- a/part2/phonebook/src/App.js +++ b/part2/phonebook/src/App.js @@ -94,6 +94,10 @@ const App = () => { .create(newPerson) .then(response => console.log(response)) + .catch(error => { + console.log(error.response.data.error) + setErrorMessage(error.response.data.error) + }) setPersons(persons.concat(newPerson)) } } -- cgit v1.2.3