Skip to content

Instantly share code, notes, and snippets.

@ahayes91
Created June 13, 2021 00:41
Show Gist options
  • Save ahayes91/783d7c4b05089393baa28a7ee265e449 to your computer and use it in GitHub Desktop.
Save ahayes91/783d7c4b05089393baa28a7ee265e449 to your computer and use it in GitHub Desktop.
Snippet to show how you can define a handler to cater for multiple requests
rest.get(
`*/assignments`,
async (req, res, ctx) => {
const status = req.url.searchParams.get('status');
if (status === 'COMPLETED,READY_FOR_SCORING,SCORING_IN_PROGRESS') {
// Note that these responses are contrived for the purpose of brevity
return res(
ctx.json({ assignments: [{ refId: 'COMPLETED_ASSIGNMENT' }] }),
);
} else {
return res(
ctx.json({ assignments: [{ refId: 'NOT_STARTED_ASSIGNMENT' }] }),
);
}
},
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment