Last active
August 29, 2015 14:18
-
-
Save shrunyan/aa6405e0de4f4458477c to your computer and use it in GitHub Desktop.
Run this with iojs to fetch the next 3 upcoming SDJS meetups
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict" | |
/** | |
* Meetup API Events Request | |
* Requests the next 3 SDJS upcoming events and returns an array of event objects | |
* @see http://www.meetup.com/meetup_api/ | |
* | |
* Go here to get your API_KEY | |
* @see https://secure.meetup.com/meetup_api/key/ | |
*/ | |
const API_KEY = 'XXXXXXXXXXXXXXXXXXXX' | |
const GROUP = 'sandiegojs' | |
const STATUS = 'upcoming' | |
const RESPONSE_LIMIT = 3 | |
let events_api_uri = `https://api.meetup.com/2/events/?key=${API_KEY}&group_urlname=${GROUP}&status=${STATUS}&page=${RESPONSE_LIMIT}` | |
let https = require('https') | |
let _ = require('lodash') | |
function parseJson (json) { | |
let events = _.map(json.results, function cb (event) { | |
return { | |
name: event.name, | |
url: event.event_url, | |
time: event.time, | |
desc: event.description | |
} | |
}) | |
console.log(events) | |
} | |
https.get(events_api_uri, function (res) { | |
let body = '' | |
res.on('data', function (d) { | |
body += d | |
}) | |
res.on('end', function () { | |
parseJson(JSON.parse(body)) | |
}) | |
}).on('error', function (e) { | |
console.log("Got error: " + e.message) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment