Created
August 1, 2018 04:37
-
-
Save rahman541/2157d91868ca0e5548501e8f73619238 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
</head> | |
<body> | |
<div id="app"> | |
{{ status }} | |
</div> | |
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> | |
<script src="https://cdn.jsdelivr.net/npm/vue"></script> | |
<script> | |
var vm = new Vue({ | |
el: '#app', | |
data: { | |
status: 'hello world' | |
}, | |
methods: { | |
loadQuote: function() { | |
this.status = 'Loading quotes...'; | |
axios.get('http://ron-swanson-quotes.herokuapp.com/v2/quotes') | |
.then((res) => { | |
this.status = res.data[0]; | |
}).catch((res) => { | |
this.status = 'Error fetching quotes'; | |
}) | |
} | |
}, | |
created: function() { | |
this.loadQuote(); | |
} | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment