mirror of
https://github.com/tenrok/axios.git
synced 2026-06-05 16:42:32 +03:00
Adding examples
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>axios - all example</title>
|
||||
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/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="/dist/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>
|
||||
Reference in New Issue
Block a user