-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update to fetch from real data source
- Loading branch information
1 parent
0afba87
commit 4121493
Showing
4 changed files
with
191 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useState, useEffect } from 'react'; | ||
|
||
function useFetchData(url) { | ||
const [data, setData] = useState(null); | ||
const [isLoading, setIsLoading] = useState(true); | ||
const [error, setError] = useState(null); | ||
|
||
useEffect(() => { | ||
fetch(url) | ||
.then(response => { | ||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
} | ||
return response.json(); | ||
}) | ||
.then(json => { | ||
setData(json); | ||
setIsLoading(false); | ||
}) | ||
.catch(err => { | ||
setError(err); | ||
setIsLoading(false); | ||
}); | ||
}, [url]); // Dependency array includes url to re-run the effect if the url changes | ||
|
||
return { data, isLoading, error }; | ||
} | ||
|
||
export default useFetchData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
export function parseWindowsUploadTcp(data) { | ||
return [900000, 901000, 500304] | ||
} | ||
|
||
export function parseWindowsDownloadTcp(data) { | ||
|
||
return [] | ||
} | ||
|
||
export function parseWindowsUploadQuic(data) { | ||
|
||
return [890000, 899999, 500304] | ||
} | ||
|
||
export function parseWindowsDownloadQuic(data) { | ||
|
||
return [] | ||
} | ||
|
||
export function parseLinuxUploadTcp(data) { | ||
|
||
return [] | ||
} | ||
|
||
export function parseLinuxDownloadTcp(data) { | ||
|
||
return [] | ||
} | ||
|
||
export function parseLinuxUploadQuic(data) { | ||
|
||
return [] | ||
} | ||
|
||
export function parseLinuxDownloadQuic(data) { | ||
|
||
return [] | ||
} | ||
|
||
export function parseCommitsList(data) { | ||
|
||
return ['xyz', 'ijk', 'abc'] | ||
} | ||
|
||
export function parseRunDates(data) { | ||
|
||
return [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters