JSFiddle - React, Tailwind, and code Playground
JavaScript
function getTweets(hashtag, latitude, longitude, pageIndex, callback) {
$.ajax({
url: 'http://api.electionguerilla.com/api/Leader/Top/1',
type:'GET',
dataType: 'jsonp',
data: {
q: hashtag,
geocode: latitude + "," + longitude + "," + '10mi',
page: pageIndex,
rpp: 10,
result_type: 'recent'
},
success: function (data, status, xmlHttp) {
alert(data);
var results = data.results;
var tweets = [];
$(results).each(function(index, tweetJSON) {
var tweet = {
created_at: 'Dhruven' + " " + pageIndex + " " + (index+1)
};
var tweetObj = JSON.stringify(tweet);
tweets.push(tweetObj);
});
callback(data.results);
}
});
}
getTweets("#facebook", 42.3580555555556, -71.0602777777778, 2, function(tweets){
$("#log").text(JSON.stringify(tweets)); })