Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adrian hodrea #5

Open
wants to merge 5 commits into
base: adrian-hodrea
Choose a base branch
from

Conversation

adrian-hodrea
Copy link

Please pull the code


function onHtmlLoaded() {

const id = window.localStorage.getItem("productId");

Choose a reason for hiding this comment

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

Good job with the event listener, the lines above being part of the onHtmlLoaded function please add the indentations to them.


function renderProducts(productsContainer, productsList) {
productsList.forEach(item => {
var { id, name, imgUrl } = item;

Choose a reason for hiding this comment

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

Please use let or const, you can do that inside a forEach loop too.


static getProductDetails(id) {
const productApiUrl = productsApiUrl + `/${id}`;
return fetch (productApiUrl,

Choose a reason for hiding this comment

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

Good job creating a separate class for Product, the getProductDetails to return a promise isn't a good practice. You can use async await it's a cleaner way or simply return the response when you're resolving the promise in the function.
For example:
instead of: Product.getProductDetails(id) .then(productData => renderProductDetails(productDetailsContainer,productData));
you can use: renderProductDetails(productDetailsContainer, Product.getProductDetails(id))

If you create a class it's better if you do an export default and than import.

Copy link

@muresanroland muresanroland left a comment

Choose a reason for hiding this comment

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

Good job Adrian!

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