-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlisting-3.8.js
More file actions
18 lines (15 loc) · 857 Bytes
/
listing-3.8.js
File metadata and controls
18 lines (15 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"use strict";
const importJsonFromRestApi = require('./toolkit/importJsonFromRestApi.js'); // Require our "importJsonFromRestApi" toolkit function.
const url = "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/significant_month.geojson";
importJsonFromRestApi(url) // Use our toolkit function to import data from the REST API.
.then(data => { // Callback to handle imported data.
const earthquakes = data.features.map(feature => { // Restructure incoming data to the CDR.
const earthquake = Object.assign({}, feature.properties, { id: feature.id });
return earthquake;
});
console.log(earthquakes); // Print the data to the console so that we can verify it.
})
.catch(err => { // Handle any error that might have occurred.
console.error("An error occurred.");
console.error(err.stack);
});