<file_sep>app.controller('nodeJSController', function($scope, $http){

    $scope.displayResults = function() {
        $scope.venueList={};
        $scope.params={
            "location":$scope.location,
            "search":$scope.search
        };
        var config = {
            headers : {
                'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
            }
        }
        var req = $http.post('http://127.0.0.1:8083/display',$scope.params);
        req.then(function(data, status, headers, config) {
            $scope.message = data;
            console.log(JSON.stringify(data.data.response.groups[0].items.length));
            for (var i = 0; i < data.data.response.groups[0].items.length;) {
                $scope.venueList[i] = {
                    "name": data.data.response.groups[0].items[i].venue.name,
                    "location": data.data.response.groups[0].items[i].venue.location.address
                };
                i++;
            }
        });
    }
});




// app.controller('searchctrl', function($scope, $http) {
//     console.log("hi");
//     $scope.getSearchResult = function() {
//
//         $http.get('http://127.0.0.1:8082/getData?searchkey='+$scope.searchitem).then(function(data)
//             {
//
//                 console.log(data.data);
//                 $scope.searchDescription = data.data.itemListElement[0].result.detailedDescription.articleBody;
//                 $scope.description = "Description:";
//                 $scope.searchimage = data.data.itemListElement[0].result.image.contentUrl;
//
//
//
//             },function(err)
//             {
//             }
//         )
//     }
// })
<file_sep>var cors = require('cors');
var request= require('request');
var express = require('express');

var app = express();

var port = process.env.PORT || 8083;

app.use(express.static(__dirname + '/public'));
app.use(cors());
app.get('/', function(req, res) {
	res.render('index');
})

app.post('/display', function (req, res) {
    console.log(req.query.searchkey);
    //console.log(req.query.searchkey2);
    var searchKeyword = req.query.searchkey;
    request("https://api.foursquare.com/v2/venues/explore?client_id=UI4R30BP32O2W3TNNZ4KUQVSXSNFHWATY3MK1XT0SDGRVY0V&client_secret=<KEY>&v=20180323&limit=3&near=" + "Kansas City"+ "&query=" + "Hospitals", function (error, data, body) {
        //Check for error
        if (error) {
            return console.log('Error:', error);
        }
        console.log(data.body);
        res.send(JSON.parse(data.body));
        //Check for right status code
        if (data.statusCode !== 200) {
            return console.log('Invalid Status Code Returned:', data.statusCode);
        }
    });
});

// app.get('/getData', function (req, res) {
//     var searchKeyword = req.query.searchkey;
//     request("https://kgsearch.googleapis.com/v1/entities:search?query="+searchKeyword+"&key=<KEY>&limit=1&indent=True", function (error, response, body) {
//         res.send(body);
//     });
//
//
//
// });

app.listen(port, function() {
	console.log('app running')
})

