Skip to content

Instantly share code, notes, and snippets.

@carbide-public
Last active January 12, 2017 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carbide-public/1077ce67842cf3f501a3b66bf254bbd0 to your computer and use it in GitHub Desktop.
Save carbide-public/1077ce67842cf3f501a3b66bf254bbd0 to your computer and use it in GitHub Desktop.
untitled
async function fetchJSON (url, options) {
let response = await fetch ('https://leprosorium.ru/api/' + url, options)
let json = await response.json ()
return json
}
let session = await fetchJSON ('auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: '{ "username": "gentlewoman", "password": "TuSuTu690" }'
})
let sessionHeaders = {
'X-Futuware-UID': session.uid,
'X-Futuware-SID': session.sid
}
let my = await fetchJSON ('my', { method: 'GET', headers: sessionHeaders })
let comments = await fetchJSON ('users/phoenyxxx/comments/', { method: 'GET', headers: sessionHeaders })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment