Don't forget to call for help if you need it in your breakout rooms!
-
What does the
async
keyword do?- Used to make a fxn asynchronous. It goes before the word fxn in es5, in es6 before the parens.
- Allows us to use the
await
keyword within the fxn. - Makes a fxn return a promise
-
What does the
await
keyword do?- Must be used in a fxn declared with the async keyword
- Allows us to access a resolved value of a promise
- It allows us to block the callstack of a fxn w/async code
- Allows us to run async code as if it were synchronous
-
Convert this function to use async / await: ( https://repl.it/@khalidwilliams/2006M3-async-await-practice )
// https://api.adviceslip.com/ function getAdvice () { fetch('https://api.adviceslip.com/advice') .then(response => response.json()) .then(adviceSlip => console.log(adviceSlip.advice)) .catch(error => console.error(error)); } getAdvice();
-
Why would you mock a network request in a test?
- Allows us to control what is returned
- Prevents us from making actual network requests, potentially saving time and money
-
At a high level, what steps are necessary to mock out a network request?
-
Other questions? Put them here: https://docs.google.com/document/d/1td50LnCOA8VbAVA0KlOjm31Ach6F5NEQCy4QxgZhmOA/edit#
Hint: Don't be afraid to look at documentation for any of these questions!