Wrap Fetch in a Broadcaster in React

InstructorJohn Lindquist

Share this video with your friends

Send Tweet

Using fetch is the most common way to retrieve remote data in JavaScript, so using our callback and closures pattern, we'll want to use fetch too. Using the async and await syntax has become more popular, but many people are surprised that an async function always returns a Promise. Since our broadcasters must always return a function (not a Promise) so that we can cancel, we have to make sure we account for that when creating our broadcasters.