Last active
August 2, 2016 14:38
-
-
Save aaronmcadam/1b6d7bdb81af5f039b563194c1cb42c1 to your computer and use it in GitHub Desktop.
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
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)); | |
}) | |
); |
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
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