<commit_before>var express = require('express');
var router = express.Router();
var request = require('request');
var Step = require('step');

var OUR_GROUP_URL_NAME = 'Free-Code-Camp-NWA';


/* GET home page. */
router.get('/', function(req, res, next) {
    res.render('index');
});

// /* GET meetup page */
 router.get('/meetup', function(req, res) {
    
    // use Step to serialize the API call
    // so we don't try to process data until
    // we've received it
    Step(        
        function getMeetupData() {
                        
            var self = this;
            
            var meetupApiUrl = 'https://api.meetup.com/2/events?group_urlname='
            + OUR_GROUP_URL_NAME 
            + '&status=upcoming&page=1';
            
            // uses the request Node library to send the get request
            request.get(meetupApiUrl, function(error, response, jsonData) {
         
                // if successful, pass along the jsonData
                // else, pass along an error
                if (!error && response.statusCode == 200) {            
                    self(null, jsonData);
                } else {
                    self(error, jsonData);
                }
            }); 
        },
        function processMeetupData(err, meetupDataJSON) {
            
            // Uh oh, there's an error. 
            // Render the error template.
            if (err !== null) {
                
                res.render('error', {
                    message: 'Error getting data from Meetup.',
                    error: err
                });
            // No error.
            // Render the meetup template.
            } else {
                                
                // throws error on 
                // meetupDAtaJSON.results[0].name
                // Why can't I access this???
                console.log('+++++++++++++++++++++');
                console.log(' ');                
                console.log("meetupDataJSON: ");
                console.log(meetupDataJSON);
                console.log(' ');
                
                // this statement returns undefined
                // console.log(meetupDataJSON['results'] );
                
                // this statement throws an error 
                // console.log(meetupDataJSON.results[0].name);
                console.log('+++++++++++++++++++++');
            
                // send the raw JSON data to the browser
                res.status(200);
                res.type('json');
                res.send(meetupDataJSON);
                res.end();
                
                // Just need to grab data out of meetupDataJSON
                // and get it into the view.
            }       
        }
    );
    
    
 });

module.exports = router;<commit_msg>tried another way of accessing JSON data -- failed<commit_after>var express = require('express');
var router = express.Router();
var request = require('request');
var Step = require('step');

var OUR_GROUP_URL_NAME = 'Free-Code-Camp-NWA';


/* GET home page. */
router.get('/', function(req, res, next) {
    res.render('index');
});

// /* GET meetup page */
 router.get('/meetup', function(req, res) {
    
    // use Step to synchronize the API call
    // so we don't try to process data until
    // we've received it
    Step(        
        function getMeetupData() {
                        
            var self = this;
            
            var meetupApiUrl = 'https://api.meetup.com/2/events?group_urlname='
            + OUR_GROUP_URL_NAME 
            + '&status=upcoming&page=1';
            
            // uses the request Node library to send the get request
            request.get(meetupApiUrl, function(error, response, jsonData) {
         
                // if successful, pass along the jsonData
                // else, pass along an error
                if (!error && response.statusCode == 200) {            
                    self(null, jsonData);
                } else {
                    self(error, jsonData);
                }
            }); 
        },
        function processMeetupData(err, meetupDataJSON) {
           
            // Uh oh, there's an error. 
            // Render the error template.
            if (err !== null) {
                
                res.render('error', {
                    message: 'Error getting data from Meetup.',
                    error: err
                });
            // No error.
            // Render the meetup template.
            } else {
                                
                // throws error on 
                // meetupDAtaJSON.results[0].name
                // Why can't I access this???
                console.log('+++++++++++++++++++++');
                console.log(' ');                
                console.log("meetupDataJSON: ");
                console.log(meetupDataJSON);
                console.log(' ');
                
                // this statement returns undefined
                // console.log(meetupDataJSON['results'] );
                
                // this statement throws an error                 
                // console.log(meetupDataJSON.results[0].name);
                console.log('+++++++++++++++++++++');
            
                // send the raw JSON data to the browser
                res.status(200);
                res.type('json');
                res.send(meetupDataJSON);
                res.end();
                
                // Just need to grab data out of meetupDataJSON
                // and get it into the view.
            }       
        }
    );
    
    
 });

module.exports = router;
{'fraction_non_alphanumeric': 0.11991584852734923, 'fraction_numerical': 0.0035063113604488078, 'mean_word_length': 1.1383058470764618, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2045173', 'n_tokens_mistral': 1482, 'n_tokens_neox': 1353, 'n_words': 360}