Skip to content

Conversation

@tomjbast
Copy link

Do you know why this broke in demo? I can't replicate and fix :(. Could it be to do with the "isLoading" variable and the API being slow?

Secondly, any advice on how the code is written and making it better. I noticed Phil writes all his code in functions, which I kind of liked.

Thanks,

Tom

<button class="normButton">Sport</button>
<button class="normButton">Entertainment</button>
</div>
<div class "searchsection">
Copy link
Contributor

Choose a reason for hiding this comment

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

missing =

<div class "searchsection">
<form class="form">
<div class="text-input">
<textarea class = "textarea" rows="1" cols="10">
Copy link
Contributor

Choose a reason for hiding this comment

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

text input would work better for single line search input

let fetchPromise = fetch('https://newsapi.org/v2/top-headlines?country=gb&apiKey=56887af3601845008f0dc6fa7f8b8810') //fetchs default page -news in UK


const Buttons = document.querySelectorAll(".normButton")
Copy link
Contributor

Choose a reason for hiding this comment

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

name variables and functions using lower case for first letter.


let textInBox = "" // variable to hold the value input to the text area
textArea.addEventListener("input", function(event) {
textInBox = event.target.value
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be easier to grab the text input content, once submit is detected. It will save writing an additional event handler and save using a global variable




/*function createCharacter(character){
Copy link
Contributor

Choose a reason for hiding this comment

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

Commented out code can be removed

@dmitrigrabov
Copy link
Contributor

Writing code in functions is always good. Keeps code clean, concise and re-usable. It looks like the infinite scroll issue is due to api call failing when query is not defined. If you try load on scroll without typing in a query, the api call fails

@dmitrigrabov
Copy link
Contributor

It would be good to see a README that explains what the code does so people reviewing your github account in future will know what you have done

@dmitrigrabov
Copy link
Contributor

To spot issues like scrolling in future take a look in dev tools for any errors. they might contain clues about what is breaking

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