This Gist was automatically created by Carbide, a free online programming environment.
Last active
January 12, 2017 11:51
-
-
Save carbide-public/1077ce67842cf3f501a3b66bf254bbd0 to your computer and use it in GitHub Desktop.
untitled
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
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