Last active
December 13, 2015 21:38
-
-
Save juandazapata/4978357 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Include the authorization tokens if we're issuing an API request. | |
# By doing this, we can call the API and the system will include the authorization headers for us. | |
# http://api.jquery.com/jQuery.ajaxPrefilter/ | |
$.ajaxPrefilter (options, originalOptions, xhr) -> | |
is_request_to_api = (options.url.indexOf('<%= Settings.API.URL %>') == 0) | |
if is_request_to_api | |
xhr.setRequestHeader('Authorization', "Token token=\"<%= Settings.API.TOKEN %>\", signature=\"<%= Settings.API.SIGNATURE %>\", timestamp=\"<%= Settings.API.TIMESTAMP %>\"") | |
return | |
# Get the user location using our API | |
$.ajax( | |
url: "<%= Settings.API.URL %>/cities/geocode.json?latitude=#{@latitude}&longitude=#{@longitude}" | |
).success( (data) => | |
console.log data | |
).error( => | |
console.log 'error' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment