Skip to content

Commit

Permalink
Sub response (#767)
Browse files Browse the repository at this point in the history
* fix: modified subscription response

* fix: modified error response
  • Loading branch information
akp111 authored Oct 11, 2023
1 parent 67abf8b commit 7d67d5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions packages/restapi/src/lib/channels/subscribeV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,17 @@ export const subscribeV2 = async (options: SubscribeOptionsV2Type) => {

};

await axios.post(requestUrl, body);
const res = await axios.post(requestUrl, body);

if (typeof onSuccess === 'function') onSuccess();

return { status: 'success', message: 'successfully opted into channel' };
} catch (err) {
console.log(err);
return { status: res.status, message: 'successfully opted into channel' };
} catch (err: any) {

if (typeof onError === 'function') onError(err as Error);

return {
status: 'error',
status: err?.response?.status?? '' ,
message: err instanceof Error ? err.message : JSON.stringify(err),
};
}
Expand Down
8 changes: 4 additions & 4 deletions packages/restapi/src/lib/channels/unsubscribeV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@ export const unsubscribeV2 = async (options: UnSubscribeOptionsV2Type) => {
message: messageInformation.data,
};

await axios.post(requestUrl, body);
const res = await axios.post(requestUrl, body);

if (typeof onSuccess === 'function') onSuccess();

return { status: 'success', message: 'successfully opted out channel' };
} catch (err) {
return { status: res.status, message: 'successfully opted into channel' };
} catch (err: any) {
if (typeof onError === 'function') onError(err as Error);

return {
status: 'error',
status: err?.response?.status?? '' ,
message: err instanceof Error ? err.message : JSON.stringify(err),
};
}
Expand Down

0 comments on commit 7d67d5b

Please sign in to comment.