Skip to content

Conversation

@KateMhq
Copy link

@KateMhq KateMhq commented Sep 16, 2018

No description provided.

newsReader.js Outdated
const keyword=document.querySelector(".keyword");
let p=1;

let urlBase = 'https://newsapi.org/v2/'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variables which will not change in future should be declared using const

newsReader.js Outdated
return response.json()
})
.then(response => {
console.log(response);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to extract the display logic into own function to keep the fetch code concise and make the display code re-usable if needed in future.

newsReader.js Outdated
articleList.appendChild(newsDetail);
i++;
}
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return is not needed

newsReader.js Outdated
.catch(error => console.log(error));


nextPageButton.onclick=function(event) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to set the event listener using addEventListener

newsReader.js Outdated
return response.json()
})
.then(response => {
console.log(response);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to see display logic in own function

newsReader.js Outdated
.then(response => {
console.log(response);

i=1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get an index number from forEach. It is the second parameter passed to it. For example,
response.articles.forEach(function(item, index){ })

i++;
document.documentElement.scrollTop = 0;
}
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return is not needed

return response.json()
})
.then(response => {
console.log(response);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as before regarding use of i and wrapping display logic in function

@dmitrigrabov
Copy link
Contributor

dmitrigrabov commented Sep 17, 2018

It would be good to see a README update which explains what the project does. Very nice work otherwise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants