Could you guys please help me structure my code?
I have this system coded in PHP already but its a TOTALLY mess becasue i dont know how to structure it in a good way. This time I am going to code the script in Javascript with axios and this time I want to do it right.
I fetch alot of data from alot of different APIs and API endpoints. Then I insert all this data into my DB.
the way i built it in PHP was _something
**File1 – a cron job
calling all the functions to grab the data. Every single function gets called 5 times with different dates. Then the data is inserted into my db
“`
funcs = [‘func1′,’func2’,func3’….] // 150 or so
dates = [‘2020-12-20’, ‘2020-12-21’,’2020-12-22’….] // 7 atm
data = []
for(i<funcs.length; i++) {
for(a<dates.length; a++) {
// grabbing one functions JSON data
data.push(a[i](dates[a]))
}
}
/*
connect to db
insert query1
insert query2
query3
query4
….
query150
*/
// close db con
**file2
A class that includes all the functions. aka func1() func2() func3()… which each returns a JSON object
the cron job is called once a day