forked from axios/axios
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
44 lines (42 loc) · 1.34 KB
/
index.html
File metadata and controls
44 lines (42 loc) · 1.34 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!doctype html>
<html>
<head>
<title>axios - all example</title>
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"/>
</head>
<body class="container">
<h1>axios.all</h1>
<div>
<h3>User</h3>
<div class="row">
<img id="useravatar" src="" class="col-md-1"/>
<div class="col-md-3">
<strong id="username"></strong>
</div>
</div>
<hr/>
<h3>Orgs</h3>
<ul id="orgs" class="list-unstyled"></ul>
</div>
<script src="/axios.min.js"></script>
<script>
axios.all([
axios.get('https://api.github.com/users/mzabriskie'),
axios.get('https://api.github.com/users/mzabriskie/orgs')
]).then(axios.spread(function (user, orgs) {
document.getElementById('useravatar').src = user.data.avatar_url;
document.getElementById('username').innerHTML = user.data.name;
document.getElementById('orgs').innerHTML = orgs.data.map(function (org) {
return (
'<li class="row">' +
'<img src="' + org.avatar_url + '" class="col-md-1"/>' +
'<div class="col-md-3">' +
'<strong>' + org.login + '</strong>' +
'</div>' +
'</li>'
);
}).join('');
}));
</script>
</body>
</html>