Start the process of splitting JS files
I am a JS noob so this is probably poorly thought out. But it is a wip and I dont really care about the quality, just more the learning experience.
This commit is contained in:
13
src/fetchData.js
Normal file
13
src/fetchData.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import Datum from "./datum";
|
||||
import urlBuilder from "./urlBuilder";
|
||||
|
||||
export default async function fetchData(currentRegionSelection, currentTimeSelection, currentAggregateSelection) {
|
||||
const data = [];
|
||||
const resp = await fetch(urlBuilder(currentRegionSelection, currentTimeSelection, currentAggregateSelection));
|
||||
const respData = await resp.json();
|
||||
for (let i = 0, l = respData.length; i < l; i++) {
|
||||
let datum = new Datum(Date.parse(respData[i]['time']), respData[i]['value']);
|
||||
data.push(datum);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
Reference in New Issue
Block a user