-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmeeting.js
36 lines (29 loc) · 985 Bytes
/
meeting.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 fetch = require('node-fetch');
const axios = require('axios');
function when(cb) {
return meetingPromise().then(json => {
cb(formateDate(json.data[0].time));
});
}
function where(cb) {
return meetingPromise().then(json => {
const maplink = `We meet at ${json.data[0].venue.name} https://www.google.com/maps/place/${json.data[0].venue.name}/@${json.data[0].venue.lat},${json.data[0].venue.lon},15z`
cb(maplink);
});
}
function what(cb) {
return meetingPromise().then(json => {
cb(json.data[0].name);
});
}
function meetingPromise() {
const promise = axios.get('https://api.meetup.com/Jax-Node-js-UG/events?page=2');
return promise;
}
function formateDate(time) {
const date = new Date(time);
return date.toLocaleDateString('en-us', { weekday:"long", year:"numeric", month:"short", day:"numeric", hour:"2-digit", minute:"2-digit"});
}
exports.when = when;
exports.where = where;
exports.what = what;