Skip to content

Commit 482a620

Browse files
committed
improve code
1 parent b6bb695 commit 482a620

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

examples/clients/auth0/vanilla.html

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,17 @@
99
var match = RegExp('[#&]access_token=([^&]*)').exec(window.location.hash);
1010
var accessToken = match && decodeURIComponent(match[1].replace(/\+/g, ' '));
1111
if (!accessToken) {
12-
redirectUri = document.location.href;
13-
url = 'https://'+domain+'/authorize?audience='+audience+'&response_type=token&client_id='+clientId+'&redirect_uri='+redirectUri;
14-
document.location = url;
12+
document.location = 'https://'+domain+'/authorize?audience='+audience+'&response_type=token&client_id='+clientId+'&redirect_uri='+document.location.href;
1513
} else {
1614
document.location.hash = '';
17-
url = '/api.php/records/posts?join=categories&join=tags&join=comments&filter=id,eq,1';
1815
var req = new XMLHttpRequest();
1916
req.onreadystatechange = function () {
2017
if (req.readyState==4) {
2118
console.log(req.responseText);
22-
jsonObject = JSON.parse(req.responseText);
23-
document.getElementById('output').innerHTML = JSON.stringify(jsonObject, undefined, 4);
19+
document.getElementById('output').innerHTML = JSON.stringify(JSON.parse(req.responseText), undefined, 4);
2420
}
2521
}
22+
url = '/api.php/records/posts?join=categories&join=tags&join=comments&filter=id,eq,1';
2623
req.open("GET", url, true);
2724
req.setRequestHeader('X-Authorization', 'Bearer '+accessToken);
2825
req.send();

0 commit comments

Comments
 (0)