Skip to content

Instantly share code, notes, and snippets.

@shrunyan
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shrunyan/aa6405e0de4f4458477c to your computer and use it in GitHub Desktop.
Save shrunyan/aa6405e0de4f4458477c to your computer and use it in GitHub Desktop.
Run this with iojs to fetch the next 3 upcoming SDJS meetups
"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