Skip to content

Instantly share code, notes, and snippets.

@JimRottinger
Last active June 13, 2019 19:48
Show Gist options
  • Save JimRottinger/fb02465094b2b5505cb326318ab295c7 to your computer and use it in GitHub Desktop.
Save JimRottinger/fb02465094b2b5505cb326318ab295c7 to your computer and use it in GitHub Desktop.
function mockServerCall () {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve({
'status': 200,
'content-type': 'application/json',
'data' : {
dataOfInterest: 42
}
})
}, 250)
})
}
mockServerCall()
.then(({data: { dataOfInterest = 100 }}) => {
console.log(dataOfInterest) // 42 (but would default to 100)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment