Skip to content

Commit

Permalink
Merge pull request #104 from ymaheshwari1/#2gnze24
Browse files Browse the repository at this point in the history
Fixed: the case when getting 404 for the getUserPreference api by handling the condition in try catch block(#2gnze24)
  • Loading branch information
adityasharma7 authored Jun 27, 2022
2 parents 21a60b9 + db888e0 commit 1d795fb
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,17 @@ const actions: ActionTree<UserState, RootState> = {
if (resp.data.userTimeZone !== localTimeZone) {
emitter.emit('timeZoneDifferent', { profileTimeZone: resp.data.userTimeZone, localTimeZone});
}
const userPreferenceResp = await UserService.getUserPreference({
'userPrefTypeId': 'BOPIS_PREFERENCE'
});
try {
const userPreferenceResp = await UserService.getUserPreference({
'userPrefTypeId': 'BOPIS_PREFERENCE'
});

if (userPreferenceResp.status == 200 && !hasError(userPreferenceResp) && userPreferenceResp.data?.userPrefValue) {
const userPreference = JSON.parse(userPreferenceResp.data.userPrefValue)
commit(types.USER_PREFERENCE_UPDATED, userPreference)
if (userPreferenceResp.status == 200 && !hasError(userPreferenceResp) && userPreferenceResp.data?.userPrefValue) {
const userPreference = JSON.parse(userPreferenceResp.data.userPrefValue)
commit(types.USER_PREFERENCE_UPDATED, userPreference)
}
} catch (err) {
console.error(err)
}
commit(types.USER_INFO_UPDATED, resp.data);
commit(types.USER_CURRENT_FACILITY_UPDATED, resp.data.facilities.length > 0 ? resp.data.facilities[0] : {});
Expand Down

0 comments on commit 1d795fb

Please sign in to comment.