parent
95f699e17a
commit
eaa131b29a
@ -1,30 +1,6 @@
|
||||
let linkService = new LinkService();
|
||||
linkService.getLinks();
|
||||
|
||||
const api = new NewsService()
|
||||
|
||||
let api = new ApiService()
|
||||
|
||||
|
||||
let res = api.get(2)
|
||||
|
||||
|
||||
async function showGets(id)
|
||||
{
|
||||
|
||||
console.group("main.js")
|
||||
let api = new ApiService()
|
||||
|
||||
let res = await api.get(id);
|
||||
|
||||
let array =[]
|
||||
|
||||
for (let i = 0; ii < 5; ii++) {
|
||||
array.push(res.articles[i]);
|
||||
|
||||
}
|
||||
console.log(res.articles[0])
|
||||
|
||||
console.groupEnd("main.js")
|
||||
|
||||
return array;
|
||||
}
|
||||
api.getNews()
|
||||
|
@ -0,0 +1,20 @@
|
||||
class NewsService{
|
||||
constructor(){}
|
||||
async getNews()
|
||||
{
|
||||
const url = "https://newsapi.org/v2/everything?q=esport&apiKey=1639059dc5a942089bd2d29db40ee7e7";
|
||||
const api = new ApiService()
|
||||
let response = api.get(url);
|
||||
|
||||
console.log("JE SUIS LA PROMISE")
|
||||
let tab = []
|
||||
response.then((value)=>{
|
||||
console.log(value)
|
||||
for (let i = 0; i < 5; i++) {
|
||||
tab.push(value[i]);
|
||||
}
|
||||
})
|
||||
return tab
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue