Skip to content

Instantly share code, notes, and snippets.

@mamezito-zz
Created December 28, 2016 10:44
Show Gist options
  • Save mamezito-zz/b900020fe9c0d9d559f5b855a92c20a7 to your computer and use it in GitHub Desktop.
Save mamezito-zz/b900020fe9c0d9d559f5b855a92c20a7 to your computer and use it in GitHub Desktop.
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