Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Conversation

@whitepiolin
Copy link

No description provided.

Copy link
Contributor

@remarcmij remarcmij left a comment

Choose a reason for hiding this comment

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

Your error handling does not work. For my other feedback, please refer to my week 2 comments.

error => {
createAndAppend('div', root, { html: error.message, class: 'alert-error', role: "alert" });
return;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Your error handler doesn't work. Have you tried it?

Copy link
Author

Choose a reason for hiding this comment

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

I corrected code. I had not noticed this error before i uploaded it

@whitepiolin
Copy link
Author

Dear @remarcmij , I have made changes by the help of your comments. Would you please reexamine my assignment ? Thanks for your efforts.

Copy link
Contributor

@remarcmij remarcmij left a comment

Choose a reason for hiding this comment

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

Almost there...

}
});
xhr.onerror = () => {
reject(alert("Opppsss, Network Error"));
Copy link
Contributor

Choose a reason for hiding this comment

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

The reject method must be called with error information that is to be passed to .catch() handlers. Here you are passing a call to alert(). The alert() function returns undefined. So the value that is passed to the .catch() is undefined. This causes the catch() handler to produce a runtime error in line 72, because it is expecting an Error object with a message property.

index.js:72 Uncaught (in promise) TypeError: Cannot read property 'message' of undefined

Moreover, you should not do any DOM manipulation or anything to do with the UI in this fetchJSON() function. This is a violation of the important principle of Separation of Concerns. The fetchJSON() should be concerned with fetching data only. In line 12 it is done correctly.

For instance, see this Stack Overflow question:

https://stackoverflow.com/questions/98734/what-is-separation-of-concerns

Copy link
Author

Choose a reason for hiding this comment

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

yes, i think it is corrected

Copy link
Author

Choose a reason for hiding this comment

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

@remarcmij Sorry for my errors. I think i understood what you mean and tried to correct it. Now i can not see an error. I hope it is done now. If you think it needs more corrections, please warn me again. Thanks

}
});
const HYF_REPOS_URL = 'https://api.github.com/orgs/HackYourFuture/repos?per_page=100';
const root = document.getElementById('root');
Copy link
Contributor

Choose a reason for hiding this comment

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

You should place this statement definition root inside function main() so that it is guaranteed to be executed through window.onload. The root div may not have been created by the browser yet when this statement is executed as this point. The 'load' event is guaranteed to executed when the web page and all its resources are completely loaded.

Copy link
Author

Choose a reason for hiding this comment

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

It is inside the main function now

remarcmij
remarcmij previously approved these changes Sep 5, 2018
Copy link
Contributor

@remarcmij remarcmij left a comment

Choose a reason for hiding this comment

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

All is well now. Thanks for following-up on the feedback.

@whitepiolin
Copy link
Author

i have seen that in 3 places root seems undefined. I have corrected them. I hope it is more better now. thanks again

@whitepiolin
Copy link
Author

whitepiolin commented Sep 5, 2018

i tried to add root as extra parameter to render functions in order to cancel undefined error.

@remarcmij remarcmij closed this Oct 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants