Answers for "using async await with array.reduce"

0

using async await with array.reduce

const fetchJobs = async () => {
  const locations = [ 'toronto', 'vancouver', 'boston' ];

  return await locations.reduce(async (jobsAccumulator, location) => {
    const jobPostingsCall = await fetch(`https://jobs.github.com/positions.json?description=javascript&location=${location}` );

    const jobPostings = await jobPostingsCall.json();

    jobsAccumulator.push({
      location,
      jobPostings,
    });

    return jobsAccumulator;
  }, []);
}

 COPY SNIPPET
Posted by: Guest on October-27-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language