<div id="app">
<h1> News Aggregator </h1>
<div v-for="CurNews in news">
<div id="title">
<h1>{{CurNews.title}}</h1>
</div>
<div id="description">
<p>{{CurNews.description}}</p>
</div>
</div>
</div>
<script>
const API_KEY = "XXXXXXXXXX";
const url = "https://newsapi.org/v1/articles?";
const app = new Vue({
el: '#app',
data:{
news: [{
title:"ABC", description: "VXAEW"
}]
},
mounted(){
axios.get("https://newsapi.org/v1/articles?source=the-times-of-india&sortBy=top&apiKey=XXXXXXXXXXX").then(function(response){
this.news = response.data.articles;
//app.$set(this.news, response.data.articles);
console.log(response.data.articles);
}).catch(function(error){
console.log(error);
})
}
});
</script>
The view does not update. Also, whenever I try to access the response/news object through the console, I get "Reference Error: response/news in not defined". The AJAX call works perfectly.