AJAX calls and external APIs

This week I added code to pull data from NYC’s Department of Parks and Recreation. They publish their Events Calendar via NYC Open Data. To get the XML data into a format I could work with in NodeJS, I used the xml2js library which converts XML to a JavaScript object which I then convert to JSON.

For now, my /nycdata route does the data crunching and adds the events from ‘today’ to my database.

I also added a modal window with the event’s data that’s loaded via an AJAX call to the database. To do this, I created another API route to return just one event by it’s ID.

You can checkout the live version in progress here: betherenyc.herokuapp.com
And follow the code on GitHub: github.com/michelleboisson/betherenyc

To do:
– either have /nycdata called once via a cron job at the beginning of the day
– check to see if today’s data has already been added to avoid duplicates.
– add a visual indicator that shows that data is being loaded via AJAX

Proudly powered by WordPress
Theme: Esquire by Matthew Buchanan.