Created
April 4, 2015 07:46
-
-
Save jmoe/09fd5828943b08f0b558 to your computer and use it in GitHub Desktop.
RIDB Test
This file contains 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
var RIDB = (function(RIDB) { | |
'use strict'; | |
var _baseurl = "https://ridb-dev.nsitellc.com/api/v1"; | |
var _apikey; | |
function showResponse(response){ | |
console.log(response); | |
} | |
function showError(response){ | |
console.log(response); | |
} | |
RIDB.init = function(opts){ | |
_apikey = opts['apikey']; | |
_baseurl = opts['baseurl'] || _baseurl; | |
console.log(_apikey); | |
// jQuery.ajaxSetup({ cache: true, headers:{apikey: _apikey} }); | |
} | |
RIDB.get = function(path){ | |
var _url = _baseurl + "/"+ path; | |
sendRequest(_url); | |
} | |
function sendRequest(url){ | |
$.ajax({ | |
cache: true, | |
headers: {apikey:_apikey}, | |
url: url, | |
type: 'GET', | |
dataType: 'json', | |
success: showResponse, | |
error: showError | |
}); | |
} | |
RIDB.organizations = function(){ | |
RIDB.get('organizations'); | |
} | |
RIDB.testOuterSpatial = function(){ | |
sendRequest('http://api.outerspatial.com/v0/trailheads'); | |
} | |
return RIDB; | |
}(RIDB || {})); | |
// RIDB.init({apikey:YOUR_API_KEY}); | |
// RIDB.organizations(); | |
// should return organizations but fails due to CORS | |
// RIDB.testOuterSpatial(); | |
// seems to work fine |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment