Skip to content

Commit

Permalink
Attempt using futures
Browse files Browse the repository at this point in the history
  • Loading branch information
meyilmaz committed Jun 26, 2013
1 parent d2ce42c commit 9c1cd46
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions server/Server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,31 @@ Meteor.methods
return resulting
false
checkCapitolWords: (query) ->
@unblock()
Future = Npm.require("fibers/future");
fut = new Future()
fut2 = new Future()
result = Meteor.http.call('GET',"http://congress.api.sunlightfoundation.com/legislators",
params:
"apikey": sunlight_api_key,
"last_name": query
"last_name": query,
,(err,res)->
return fut.ret(res)
)
result = fut.wait()
console.log( query + " is query")
if result.statusCode is 200
resulting = JSON.parse(result.content);
console.log( resulting.results[0].bioguide_id )
bioguide_id = resulting.results[0].bioguide_id
@unblock()
capitol_by_leg = Meteor.http.call('GET',"http://capitolwords.org/api/1/phrases.json"
params:
"apikey": sunlight_api_key,
"entity_type": "legislator",
"entity_value": bioguide_id
(err,res)->
return fut2.ret(res)
)
capitol_by_leg = fut2.wait()
if capitol_by_leg.statusCode is 200
resulting = JSON.parse(capitol_by_leg.content);
resulting.sort (a, b)->
Expand Down

0 comments on commit 9c1cd46

Please sign in to comment.