Skip to content

Instantly share code, notes, and snippets.

@rye761
Created February 13, 2018 19:12
Show Gist options
  • Save rye761/188ce6f5a139876b2d180982662622ff to your computer and use it in GitHub Desktop.
Save rye761/188ce6f5a139876b2d180982662622ff to your computer and use it in GitHub Desktop.
<html>
<head>
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<title>Ron Swanson Quote</title>
</head>
<body>
<div id="app">
<p>{{ status }}</p>
</div>
<script>
var app = new Vue({
el: '#app',
data: {
status: ''
},
created: function () {
this.loadQuote();
},
methods: {
loadQuote: function () {
this.status = 'Loading...';
var vm = this;
axios.get('http://ron-swanson-quotes.herokuapp.com/v2/quotes')
.then(function (response) {
vm.status = response.data[0];
})
.catch(function (error) {
vm.status = 'Sorry! An error occurred: ' + error;
});
}
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment