Vue
by Umesh Patil
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js"></script>
<div id="app">
{{loadedData}}
</div>
CSS
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
}
li {
margin: 8px 0;
}
h2 {
font-weight: bold;
margin-bottom: 15px;
}
del {
color: rgba(0, 0, 0, 0.3);
}
Vue
new Vue({
el: "#app",
data: {
loadedData:""
},
mounted(){
this.loadData()
},
methods: {
toggle: function(todo){
todo.done = !todo.done
},
loadData(){
axios.post('https://coolql.cool/graphql', { query: `{
site(url: "https://news.ycombinator.com") {
titles: selectAll(elem: "tr.athing") {
id: attr(name: "id")
numberOfLinks: count(elem: ".storylink")
link: selectAll(elem: ".storylink") {
text
href
class
classList
}
}
}
}` })
.then((res) => {
this.loadedData = res.data.data.site.titles
})
}
}
})