-
-
Save klinkov/42397d5add63aadf0ceb864f762ec393 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