Created
June 13, 2021 00:41
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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