Last active
June 13, 2019 19:48
-
-
Save JimRottinger/fb02465094b2b5505cb326318ab295c7 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
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