-
Notifications
You must be signed in to change notification settings - Fork 9
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
base: adrian-hodrea
Are you sure you want to change the base?
Adrian hodrea #5
Conversation
|
||
function onHtmlLoaded() { | ||
|
||
const id = window.localStorage.getItem("productId"); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
frontend/models/Product.js
Outdated
|
||
static getProductDetails(id) { | ||
const productApiUrl = productsApiUrl + `/${id}`; | ||
return fetch (productApiUrl, |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job Adrian!
Please pull the code