jpreardon / good-morning-display

A simple display for useful information, especially in the morning (e.g. weather and transit info).
http://jpreardon.com/projects/good-morning-display/
Other
2 stars 0 forks source link

DRY up fetch() calls #31

Closed jpreardon closed 3 years ago

jpreardon commented 3 years ago

With the introduction of fetch(), there are a lot of these if statements that can be moved to a handleErrors function:

if (res.ok) {
  return res.json()
} else {
  throw new Error(res.status);
}

Here's an example of that: https://www.tjvantoll.com/2015/09/13/fetch-and-errors/

This is part of #19