pixelastic / meetup-random-user

Pick a random attendee from any meetup event
https://pixelastic.github.io/meetup-random-user/
4 stars 1 forks source link

Meetup loads attendees lazily now #3

Closed caugner closed 4 years ago

caugner commented 6 years ago

To reproduce:

  1. Go to https://pixelastic.github.io/meetup-random-user/
  2. Paste https://www.meetup.com/fr-FR/Paris-js/events/249735887/
  3. Click on Pick one.

Request headers:

GET /meetup-random-user?url=https%3A%2F%2Fwww.meetup.com%2Ffr-FR%2FParis-js%2Fevents%2F249735887%2F HTTP/1.1
Host: wt-a2f9d5672798ac7ef42b871652a58fb0-0.run.webtask.io
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://pixelastic.github.io/meetup-random-user/
Origin: https://pixelastic.github.io
Connection: keep-alive

Response headers:

HTTP/1.1 500 OK
Server: webtask
x-wt-response-source: webtask
Access-Control-Allow-Origin: https://pixelastic.github.io
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: x-auth0-proxy-stats, x-auth0-stats, x-wt-response-source, location
x-auth0-proxy-stats: {"proxy_host":"172.31.200.121","proxy_pid":62,"container_id":"76113ac5-053e-4cd9-83c1-911ae607fee6","latency":779,"uptime":22053.158,"memory":{"rss":110993408,"heapTotal":58793984,"heapUsed":45874240,"external":19550195},"req_id":"1524677937111.631766"}
content-type: application/json
x-wt-recycling: 1
x-auth0-stats: {"worker_pid":7,"response":{"200":1,"500":1},"time":720,"uptime":51.554,"memory":{"rss":46452736,"heapTotal":25766912,"heapUsed":23314664,"external":114553}}
date: Wed, 25 Apr 2018 17:38:57 GMT
transfer-encoding: chunked
Connection: keep-alive

Response:

{
  "code": 500,
  "error": "Script generated an unhandled asynchronous exception.",
  "details": "TypeError: Cannot read property 'match' of undefined",
  "name": "TypeError",
  "message": "Cannot read property 'match' of undefined",
  "stack": "TypeError: Cannot read property 'match' of undefined\n    at Request._callback (/data/io/4b433d39-2139-4f3e-b2a0-8e8aabbbe5fd/webtask.js:25:14)\n    at Request.self.callback (/data/sandbox/node_modules/request/request.js:186:22)\n    at emitTwo (events.js:87:13)\n    at Request.emit (events.js:172:7)\n    at Request.<anonymous> (/data/sandbox/node_modules/request/request.js:1163:10)\n    at emitOne (events.js:77:13)\n    at Request.emit (events.js:169:7)\n    at IncomingMessage.<anonymous> (/data/sandbox/node_modules/request/request.js:1085:12)\n    at IncomingMessage.g (events.js:260:16)\n    at emitNone (events.js:72:20)"
}
caugner commented 6 years ago

Actually, yarn run test doesn't pass locally either:

yarn run v1.5.1
$ node test.js
/home/mozilla/git/meetup-random-user/webtask/meetup-random-user.js:25
      id: url.match(/\/(\d+)/)[1],
             ^

TypeError: Cannot read property 'match' of undefined
    at Request._callback (/home/user/git/meetup-random-user/webtask/meetup-random-user.js:25:14)
    at Request.self.callback (/home/user/git/meetup-random-user/node_modules/request/request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/home/user/git/meetup-random-user/node_modules/request/request.js:1163:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/home/user/git/meetup-random-user/node_modules/request/request.js:1085:12)
    at IncomingMessage.g (events.js:292:16)
    at emitNone (events.js:91:20)
error An unexpected error occurred: "Command failed.
Exit code: 1
caugner commented 6 years ago

The problem seems to be that the Meetup /attendees endpoint does not return the user list directly, but rather loads it in a separate ajax request.

For example, the attendee list for the aforementioned meetup is fetched via https://www.meetup.com/mu_api/urlname/events/eventId/attendees?queries=(endpoint:Paris-js/events/244179664/attendance,meta:(method:get),params:(desc:!t,fields:'self,web_actions,answers,pay_status',order:time),ref:eventAttendance_Paris-js_244179664,type:attendance) (and requires a CSRF token).

caugner commented 6 years ago

Here's a workaround to pick a random meetup user in the browser (from the attendees list):

  1. Open up the DevTools.
  2. Type this:
    let users = document.querySelectorAll('.attendee-item');
    let user = users[Math.floor(Math.random() * users.length)];
    document.body.innerHTML = user.innerHTML;