Skip to content

Commit

Permalink
fix: don't throw instantly if mock server doesnt return 2xx
Browse files Browse the repository at this point in the history
  • Loading branch information
naftis committed Dec 11, 2024
1 parent 31bbe14 commit f4fbde3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
10 changes: 1 addition & 9 deletions packages/server/src/mosip-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const postBirthRecord = async ({
}>;
};

export const postDeathRecord = async ({ nid }: { nid: string }) => {
export const deactivateNid = async ({ nid }: { nid: string }) => {
const response = await fetch(env.MOSIP_DEATH_WEBHOOK_URL, {
method: "POST",
body: JSON.stringify({ nid }),
Expand All @@ -47,13 +47,5 @@ export const postDeathRecord = async ({ nid }: { nid: string }) => {
},
});

if (!response.ok) {
throw new MOSIPError(
`Failed to post record to MOSIP. Status: ${
response.status
}, response: ${await response.text()}`
);
}

return response;
};
2 changes: 1 addition & 1 deletion packages/server/src/webhooks/opencrvs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const opencrvsHandler = async (

if (eventType === EVENT_TYPE.DEATH) {
const nid = getDeceasedNid(request.body);
const response = await mosip.postDeathRecord({
const response = await mosip.deactivateNid({
nid,
});
const registrationNumber = generateRegistrationNumber(trackingId);
Expand Down

0 comments on commit f4fbde3

Please sign in to comment.