-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrawler.js
36 lines (32 loc) · 845 Bytes
/
crawler.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
35
36
const url = 'https://www.ecobici.cdmx.gob.mx/availability_map/getJsonObject';
async function getData() {
const response = await fetch(url, { method: 'POST' });
const stations = await response.json();
return {
type: 'FeatureCollection',
features: stations.map(mapStation),
};
}
function mapStation(station) {
return {
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [
station.lon,
station.lat,
]
},
properties: {
id: station.id,
address: station.address,
district: station.district,
name: station.name,
nearby_stations: station.nearbyStations.split(','),
station_types: station.stationType.split(','),
zip_code: station.zip,
},
};
}
getData()
.then((collection) => console.log(JSON.stringify(collection, null, 2)));