T-Sajad / football-scores-app

1 stars 0 forks source link

Consolidate common script code #5

Open josephjclark opened 10 months ago

josephjclark commented 10 months ago

Have you noticed that all your request scripts have almost exactly the same code?

They all do this, for example:

try {
  const response = await fetch(url, options);
  const result = await response.text();
  fs.writeFileSync('./data/get-code.json', result);
} catch (error) {
  console.error(error);
}

Rather than duplicating that code over so many files, can you think of a way to create a helper or library function which makes this easier?