Skip to content

Instantly share code, notes, and snippets.

@elialejandro
Created September 26, 2019 17:29
Show Gist options
  • Save elialejandro/bec6273f46a11a76e909bc3b1a9a97e2 to your computer and use it in GitHub Desktop.
Save elialejandro/bec6273f46a11a76e909bc3b1a9a97e2 to your computer and use it in GitHub Desktop.
Demo, Vue + Axios
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="app">
<ul>
<li v-for="item in datos">
{{ item.id }} - {{ item.name }}
</li>
</ul>
</div>
</body>
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<script src="https://unpkg.com/[email protected]/dist/axios.min.js"></script>
<script>
new Vue({
el: "#app",
data: {
saludo: 'Hola vue',
datos: [],
},
mounted () {
this.cargarDatos();
},
methods: {
cargarDatos() {
axios.get( 'https://jsonplaceholder.typicode.com/users' )
.then( request => {
console.log(request.data);
this.datos = request.data;
})
}
}
})
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment