Skip to content

Instantly share code, notes, and snippets.

@aaronmcadam
Last active August 2, 2016 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronmcadam/1b6d7bdb81af5f039b563194c1cb42c1 to your computer and use it in GitHub Desktop.
Save aaronmcadam/1b6d7bdb81af5f039b563194c1cb42c1 to your computer and use it in GitHub Desktop.
const fetchResponse = (responseId, projectId) => (
callBizApi(getEndpoints(responseId))
.then(initialData => {
const response = initialData.response;
const taskId = response.taskId;
const participantId = response.participant.id;
return callBizApi(getRelationEndpoints(projectId, taskId, participantId))
.then(relationData => (
mapResponse({
response,
questions: relationData.questions,
assets: relationData.assets,
participant: relationData.participant
})
))
.catch(error => Promise.reject(error));
})
);
router.route('/projects/:projectId/responses/:responseId')
.get((req, res) => {
fetchResponse(...R.props(['responseId', 'projectId'], req.params))
.then(response => res.json(response))
.catch(sendError(res));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment