Don't forget to call for help if you need it in your breakout rooms!
- What does the
async
keyword do?
Its a key word that comes before declaring a function that allows a function to be asyncronous (use the await key word). Makes your functions return a promise as opposed to a value
- What does the
await
keyword do?
It pauses the function, and only continues after what's being resolved after await. It allows us to access a resolved value of a promise. Allows us to block call stack of function with async code Allows us to run async code as though it were synconous "Don't run anything bellow this promise we are awaiting until that promise has resolved"
-
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?
Gives us control of the data being recieved for a component, and saves us time and money by not actullly doing real requests.
- 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!