Skip to content

Commit

Permalink
Simplify examples, reference mkdocs variables
Browse files Browse the repository at this point in the history
  • Loading branch information
campb303 committed Apr 2, 2021
1 parent d5f573d commit 28ad8a1
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions docs/api/get_access_token.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
const accessToken = (async _ => {
const loginInit = {
fetch(
"{{ production_url }}/api/login",
{
method: "POST",
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ "username": USERNAME, "password": PASSWORD})
};

let loginResponse = await fetch("https://engineering.purdue.edu/webqueue/webqueue2/build/api/login", loginInit);
let data = await loginResponse.json();

if (data === null){
return false;
}

if (!loginResponse.ok){
console.error(`Login failed. Got code ${loginResponse.status} (${loginResponse.statusText})`);
return false;
}

return data.access_token || false;
})();
)
.then( resp => resp.json() )
.then( data => console.log( data.access_token ))

0 comments on commit 28ad8a1

Please sign in to comment.