Skip to content

Instantly share code, notes, and snippets.

@ties
Last active September 2, 2016 17:36
Show Gist options
  • Select an option

  • Save ties/217dd6e87b0d97e95c4597739ab16d5a to your computer and use it in GitHub Desktop.

Select an option

Save ties/217dd6e87b0d97e95c4597739ab16d5a to your computer and use it in GitHub Desktop.
// with Babel do-expression-transform <https://babeljs.io/docs/plugins/transform-do-expressions/>
function(lhs, rhs) {
return do {
if (lhs) {
Api.fromJS(lhs)
} else {
res.firstField = do {
if (rhs) {
List(rhs.map((vt) => SomeClass.fromJS(vt)))
} else {
List()
}
}
}
}
// ...
/**
* Perform the request by first setting up all the needed options and finally
* returning the promise.
*/
async doRequest(preparedRequest) {
winston.debug(`${preparedRequest.method} ${preparedRequest.url}`)
const response = await this.axios.request(preparedRequest)
if (response.status !== 200) {
throw new Error(`Http request not succesfull (status ${response.status})`, response)
}
return response.data
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment