Created
February 13, 2018 19:12
-
-
Save rye761/188ce6f5a139876b2d180982662622ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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