diff --git a/src/modules/notification/index.ts b/src/modules/notification/index.ts index 1365006..33fae20 100644 --- a/src/modules/notification/index.ts +++ b/src/modules/notification/index.ts @@ -24,7 +24,11 @@ async function getNotificationEnumIds(enumTypeId: string): Promise { throw resp.data; } } catch (err) { - return Promise.reject(err) + return Promise.reject({ + code: 'error', + message: 'Something went wrong', + serverResponse: err + }) } } @@ -52,7 +56,11 @@ async function getNotificationUserPrefTypeIds(applicationId: string, userLoginId throw resp.data; } } catch (err) { - return Promise.reject(err) + return Promise.reject({ + code: 'error', + message: 'Something went wrong', + serverResponse: err + }) } } @@ -76,7 +84,11 @@ async function storeClientRegistrationToken(registrationToken: string, deviceId: throw resp.data; } } catch (err) { - return Promise.reject(err) + return Promise.reject({ + code: 'error', + message: 'Something went wrong', + serverResponse: err + }) } } @@ -100,7 +112,11 @@ async function removeClientRegistrationToken(deviceId: string, applicationId: st throw resp.data; } } catch (err) { - return Promise.reject(err) + return Promise.reject({ + code: 'error', + message: 'Something went wrong', + serverResponse: err + }) } } @@ -123,7 +139,11 @@ async function subscribeTopic(topicName: string, applicationId: string): Promise throw resp.data; } } catch (err) { - return Promise.reject(err) + return Promise.reject({ + code: 'error', + message: 'Something went wrong', + serverResponse: err + }) } } @@ -146,7 +166,11 @@ async function unsubscribeTopic(topicName: string, applicationId: string): Promi throw resp.data; } } catch (err) { - return Promise.reject(err) + return Promise.reject({ + code: 'error', + message: 'Something went wrong', + serverResponse: err + }) } } diff --git a/src/modules/order/index.ts b/src/modules/order/index.ts index f0b2ac8..5e26c42 100644 --- a/src/modules/order/index.ts +++ b/src/modules/order/index.ts @@ -23,7 +23,7 @@ export async function getOrderDetails (orderId: string): Promise 0) { const group = resp.data.grouped.orderId.groups[0] @@ -56,7 +56,7 @@ export async function getOrderDetails (orderId: string): Promise, facilityI return Promise.reject({ code: "error", message: "Unable to find the stock for products", - serverResponse: "" + serverResponse: resp.data }) } } catch(err) { @@ -84,7 +84,7 @@ async function fetchProductsStock(productIds: Array): Promise { } else { return Promise.reject({ code: 'error', - message: 'Something went wrong', - serverResponse: 'Failed to fetch user profile information' + message: 'Failed to fetch user profile information', + serverResponse: resp.data }) } } catch(err) { @@ -82,10 +82,18 @@ async function setProductIdentificationPref(eComStoreId: string, productIdentifi if(!hasError(resp)) { return Promise.resolve(productIdentificationPref) } else { - return Promise.reject(resp) + return Promise.reject({ + code: 'error', + message: 'Failed to set product identification pref', + serverResponse: resp.data + }) } } catch(err) { - return Promise.reject(err) + return Promise.reject({ + code: 'error', + message: 'Something went wrong', + serverResponse: err + }) } } @@ -171,7 +179,11 @@ async function logout(): Promise { return Promise.resolve(resp.data) } catch(err) { - return Promise.reject(err) + return Promise.reject({ + code: 'error', + message: 'Something went wrong', + serverResponse: err + }) } } @@ -219,8 +231,8 @@ async function getUserFacilities(token: any, baseURL: string, partyId: string, f } else { return Promise.reject({ code: 'error', - message: 'Something went wrong', - serverResponse: 'Failed to fetch user facilities' + message: 'Failed to fetch user facilities', + serverResponse: resp.data }) } } catch(error: any) { @@ -250,7 +262,11 @@ async function getUserPreference(token: any, baseURL: string, userPrefTypeId: st } return Promise.resolve(resp.data.userPrefValue ? JSON.parse(resp.data.userPrefValue) : {}); } catch (err) { - return Promise.reject(err) + return Promise.reject({ + code: 'error', + message: 'Something went wrong', + serverResponse: err + }) } } @@ -268,7 +284,11 @@ async function setUserPreference(payload: any): Promise { throw resp.data } } catch (err) { - return Promise.reject(err) + return Promise.reject({ + code: 'error', + message: 'Something went wrong', + serverResponse: err + }) } } @@ -286,7 +306,11 @@ const setUserLocale = async (payload: any): Promise => { throw resp.data } } catch (error) { - return Promise.reject(error) + return Promise.reject({ + code: 'error', + message: 'Something went wrong', + serverResponse: error + }) } }