Created
December 28, 2016 10:44
-
-
Save mamezito-zz/b900020fe9c0d9d559f5b855a92c20a7 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
send = -> | |
xhr = new XMLHttpRequest | |
url = baseUrl | |
xhr.open 'POST', url, true | |
xhr.setRequestHeader 'Content-type', 'application/json' | |
xhr.setRequestHeader 'Authorization', 'Bearer ' + accessToken | |
xhr.onreadystatechange = -> | |
if xhr.readyState == 4 and xhr.status == 200 | |
print JSON.parse(xhr.responseText) | |
return | |
data = JSON.stringify( | |
query: text | |
lang: 'en' | |
sessionId: '01234') | |
xhr.send data | |
return | |
send() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment