From 6c13690b53443a81e7b73557f0e90d333d8d0385 Mon Sep 17 00:00:00 2001 From: Anna Wen <54281166+annawen1@users.noreply.github.com> Date: Wed, 3 Feb 2021 16:15:00 -0500 Subject: [PATCH] fix(profile): catch error for profile api and console log error (#5088) ### Related Ticket(s) [Unhandled Runtime Error #32](https://github.com/carbon-design-system/carbon-for-ibm-dotcom-nextjs-template/issues/32) ### Description Catch the profile api call error and console log it in attempt to prevent error overlay from appearing in nextjs template dev mode. ### Changelog **Changed** - catch error and console log while returning `Unauthenticated` --- packages/services/src/services/Profile/Profile.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/services/src/services/Profile/Profile.js b/packages/services/src/services/Profile/Profile.js index e5981b65f2e..9f47ac24baa 100644 --- a/packages/services/src/services/Profile/Profile.js +++ b/packages/services/src/services/Profile/Profile.js @@ -50,7 +50,11 @@ class ProfileAPI { }, withCredentials: true, }) - .then(response => response.data); + .then(response => response.data) + .catch(error => { + console.log('Failed Profile Network Call', error); + return { user: 'Unauthenticated' }; + }); } }