File tree Expand file tree Collapse file tree 1 file changed +19
-14
lines changed Expand file tree Collapse file tree 1 file changed +19
-14
lines changed Original file line number Diff line number Diff line change @@ -39,20 +39,25 @@ async function start() {
39
39
40
40
async function getMetric ( metric ) {
41
41
const url = `https://analytics.services.netlify.com/v1/${ siteId } /${ metric } ?from=${ startDate . getTime ( ) . toFixed ( ) } &to=${ endDate . getTime ( ) } &timezone=${ timezone } &resolution=day` ;
42
- var res = await fetch ( url , {
43
- "credentials" : "include" ,
44
- "headers" : {
45
- "Content-Type" : "application/json" ,
46
- "Authorization" : `Bearer ${ token } ` ,
47
- "Pragma" : "no-cache" ,
48
- "Cache-Control" : "no-cache"
49
- } ,
50
- "method" : "GET" ,
51
- "mode" : "cors"
52
- } ) ;
53
-
54
- const response = await res . json ( ) ;
55
- writeToCSV ( response . data , metric ) ;
42
+ try {
43
+ var res = await fetch ( url , {
44
+ "credentials" : "include" ,
45
+ "headers" : {
46
+ "Content-Type" : "application/json" ,
47
+ "Authorization" : `Bearer ${ token } ` ,
48
+ "Pragma" : "no-cache" ,
49
+ "Cache-Control" : "no-cache"
50
+ } ,
51
+ "method" : "GET" ,
52
+ "mode" : "cors"
53
+ } ) ;
54
+
55
+ const response = await res . json ( ) ;
56
+ writeToCSV ( response . data , metric ) ;
57
+ } catch ( e ) {
58
+ console . error ( "Request failed" . url ) ;
59
+ console . error ( e ) ;
60
+ }
56
61
}
57
62
58
63
function writeToCSV ( data , metric ) {
You can’t perform that action at this time.
0 commit comments