-
Notifications
You must be signed in to change notification settings - Fork 0
/
dynamicpages.js
34 lines (31 loc) · 1.06 KB
/
dynamicpages.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const fetch = require('node-fetch');
const fs = require('fs');
fetch('https://covidcasesbythenumbers.netlify.app/.netlify/functions/states', {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
})
.then(result => result.json())
.then(res => {
let result = res;
var entries = [];
for(i = 0; i < result.data.length; i++ ){
entries.push(result.data[i])
}
fetch('https://covidcasesbythenumbers.netlify.app/.netlify/functions/usa', {
method: 'GET',
headers: {'Content-Type': 'application/json' },
})
.then(result => result.json())
.then(res =>{
entries.push(res.data);
fs.writeFile('./dynamicPages.json', JSON.stringify(entries), err => {
if (err) {
console.error('Error writing dynamic pages file', err);
} else {
console.log('Dynamic pages successfully written!');
}
});
}
)
}
)