Total Complexity | 1 |
Complexity/F | 0 |
Lines of Code | 12 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | const fetchData = (url: string) => |
||
2 | fetch(url) |
||
3 | .then(res => { |
||
4 | if (!res.ok) { |
||
5 | throw new Error('Fiasco when trying to fetch data') |
||
6 | // https://react-query.tanstack.com/guides/query-functions#usage-with-fetch-and-other-clients-that-do-not-throw-by-default |
||
7 | } |
||
8 | return res.json() |
||
9 | }) |
||
10 | .catch(console.error) |
||
11 | |||
12 | export { fetchData } |
||
13 |