fixe about v-for in home module

master
Aurian JAULT 2 years ago
parent 16cdd797d6
commit 43b8eee1fd

@ -1,7 +1,7 @@
class NewsService{ class NewsService{
constructor(){} constructor(){}
async getNews(){ getNews(){
const url = "https://newsapi.org/v2/everything?q=esport&apiKey=1639059dc5a942089bd2d29db40ee7e7"; const url = "https://newsapi.org/v2/everything?q=esport&apiKey=1639059dc5a942089bd2d29db40ee7e7";
const api = new ApiService() const api = new ApiService()
let response = api.get(url); let response = api.get(url);

@ -1,6 +1,6 @@
export default{ export default{
props:{ props:{
news:[] news:Array
}, },
data:function(){ data:function(){
return {} return {}
@ -9,8 +9,8 @@ export default{
}, },
template:` template:`
<h2>Home</h2> <h2>Home</h2>
<div id="Teams" v-for="nouv in news"> <div id="Teams">
<news-card title="nouv.title" date="nouv.publishedAt"/> <news-card v-for="nouv in news" :title="nouv.title" :date="nouv.publishedAt"/>
</div> </div>
` `
} }

@ -26,13 +26,12 @@ export default{
clickHome: function() { clickHome: function() {
if(!this.homeClicked){ if(!this.homeClicked){
const api = new NewsService(); const api = new NewsService();
this.news = api.getNews();
console.log(this.news);
this.homeClicked=true;
this.teamClicked=false;
let infos = api.getNews(); let infos = api.getNews();
console.log(infos) console.log(infos)
this.news = infos this.news = infos
this.homeClicked=true;
this.teamClicked=false;
} }
else{ else{
this.homeClicked=false; this.homeClicked=false;

Loading…
Cancel
Save