Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript promise.all

// PARALLEL PROMISES
async function fetchMoviesAndCategories() {
  const [moviesResponse, categoriesResponse] = await Promise.all([
    fetch('/movies'),
    fetch('/categories')
  ]);

  const movies = await moviesResponse.json();
  const categories = await categoriesResponse.json();

  return [movies, categories];
}
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #javascript
ADD COMMENT
Topic
Name
3+1 =