Last active
November 25, 2015 19:18
-
-
Save fguisso/071bc3119e288894d6a0 to your computer and use it in GitHub Desktop.
APIRest
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 req = new XMLHttpRequest(); | |
var data = {}; | |
if('withCredentials' in req){ | |
req.open('GET', 'https://api.blinktrade.com/api/v1/BRL/ticker', true); | |
req.setRequestHeader('Content-Type', 'application/json'); | |
req.onreadystatechange = function() { | |
if (req.readyState === 4) { | |
if (req.status >= 200 && req.status < 400) { | |
data = req.responseText; | |
console.log(req.response); | |
console.log(JSON.parse(req.responseText)); | |
}else{ | |
console.log('Erro!'); | |
}; | |
}; | |
}; | |
}; |
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 request = new XMLHttpRequest(); | |
request.open('GET', 'https://api.blinktrade.com/api/v1/BRL/ticker', true); | |
request.setRequestHeader("X-Requested-With", "XMLHttpRequest"); | |
request.onload = function (res) { | |
if (request.status >= 200 && request.status < 400) { | |
res = request.responseText; | |
}; | |
}; | |
request.onerror = function(){ | |
console.log('Erro!') | |
}; | |
request.send(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment