2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-11 18:02:32 +03:00

Adding examples

This commit is contained in:
mzabriskie
2015-02-03 01:24:38 -07:00
parent e880940099
commit 7efc095582
7 changed files with 175 additions and 82 deletions
+33
View File
@@ -0,0 +1,33 @@
<!doctype html>
<html>
<head>
<title>axios - get 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.get</h1>
<ul id="people" class="list-unstyled"></ul>
<script src="/dist/axios.min.js"></script>
<script>
axios.get('people.json')
.then(function (response) {
document.getElementById('people').innerHTML = response.data.map(function (person) {
return (
'<li class="row">' +
'<img src="https://avatars.githubusercontent.com/u/' + person.avatar + '?s=50" class="col-md-1"/>' +
'<div class="col-md-3">' +
'<strong>' + person.name + '</strong>' +
'<div>Github: <a href="https://github.com/' + person.github + '" target="_blank">' + person.github + '</a></div>' +
'<div>Twitter: <a href="https://twitter.com/' + person.twitter + '" target="_blank">' + person.twitter + '</a></div>' +
'</div>' +
'</li><br/>'
);
}).join('');
})
.catch(function(data) {
document.getElementById('people').innerHTML = '<li class="text-danger">' + data + '</li>';
});
</script>
</body>
</html>
+26
View File
@@ -0,0 +1,26 @@
[
{
"name": "Matt Zabriskie",
"github": "mzabriskie",
"twitter": "mzabriskie",
"avatar": "199035"
},
{
"name": "Ryan Florence",
"github": "rpflorence",
"twitter": "ryanflorence",
"avatar": "100200"
},
{
"name": "Kent C. Dodds",
"github": "kentcdodds",
"twitter": "kentcdodds",
"avatar": "1500684"
},
{
"name": "Chris Esplin",
"github": "deltaepsilon",
"twitter": "chrisesplin",
"avatar": "878947"
}
]