-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathadmin.js
More file actions
30 lines (27 loc) · 778 Bytes
/
admin.js
File metadata and controls
30 lines (27 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
$(document).ready(function(){
var API_URL = "https://littlehelpers.herokuapp.com/admin/1";
$.ajax({
url: `${API_URL}`,
headers:{'Authorization': `Bearer ${localStorage.token}`},
type: 'GET'
}).then(function(data){
console.log(data)
for(var i=0; i<data.length; i++){
var adminSource = $("#admin-template").html();
var adminTemplate = Handlebars.compile(adminSource);
var userNames = {
"user": data[i].name
}
$('#users').append(adminTemplate(userNames));
}
});
function logOut(){
$("#logout").click(function(){
console.log('logout')
localStorage.removeItem("id");
localStorage.removeItem("token");
window.location = "/index.html";
});
}
logOut()
})