A Pen by Irvan Kadhafi on CodePen.
Created
March 23, 2020 10:36
-
-
Save irvankadhafi/bd22430cacc08b13715e69512db43c34 to your computer and use it in GitHub Desktop.
Blogger API + Vue
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
<div id="app"> | |
<!-- <div class="wrapper"> | |
<h1 class="titleblog">{{bloggerData.items[2].title}}</h1> | |
<div class="contentblog" v-html="bloggerData.items[2].content"> | |
</div> --> | |
<div class="wrapper" v-for="post in posts"> | |
<h1 class="titleblog">{{post.title}}</h1> | |
<div class="contentblog" v-html="post.content"> | |
<div> | |
</div> |
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
new Vue({ | |
el: '#app', | |
data(){ | |
return{ | |
posts: {} | |
} | |
}, | |
mounted(){ | |
this.getPosts(); | |
}, | |
methods:{ | |
getPosts(address){ | |
axios.get(address ? address: "https://www.googleapis.com/blogger/v3/blogs/7069086342349432598/posts?key=AIzaSyBTbqfjroUfKvYFF4G9At0niGe-bDkoVmA") .then(response => { | |
this.posts = response.data.items; | |
}); | |
}, | |
navigate(address) { | |
this.getPosts(address) | |
} | |
} | |
}); |
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
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js"></script> | |
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> |
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
.wrapper { | |
background: #ccc none repeat scroll 0 0; | |
border: 1px solid #ccc; | |
margin: 50px; | |
padding: 20px; | |
} | |
.titleblog { | |
background: #f7f7f7 none repeat scroll 0 0; | |
color: #ccc; | |
margin: 0 0 20px; | |
padding: 10px; | |
text-align: center; | |
text-shadow: 1px 1px 1px #000; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment