fix: improve error handling
This commit is contained in:
parent
9523152165
commit
010aa2c2fc
1 changed files with 6 additions and 1 deletions
|
@ -39,13 +39,18 @@ export async function loginUserToken({ authToken }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function storeFcmToken({ deviceId, fcmToken }) {
|
export async function storeFcmToken({ deviceId, fcmToken }) {
|
||||||
const { data } = await network.apolloClient.mutate({
|
const { data, errors } = await network.apolloClient.mutate({
|
||||||
mutation: STORE_FCM_TOKEN_MUTATION,
|
mutation: STORE_FCM_TOKEN_MUTATION,
|
||||||
variables: {
|
variables: {
|
||||||
deviceId,
|
deviceId,
|
||||||
fcmToken,
|
fcmToken,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
if (errors && errors.length > 0) {
|
||||||
|
// Concatenate all error messages
|
||||||
|
const message = errors.map((err) => err.message).join("; ");
|
||||||
|
throw new Error(`GraphQL Error: ${message}`);
|
||||||
|
}
|
||||||
const { updatedAt } = data.updateOneDevice;
|
const { updatedAt } = data.updateOneDevice;
|
||||||
return { updatedAt };
|
return { updatedAt };
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue