add this line at the top of the file: import fs from 'fs';
it is because of heroku policy for free dyno. It delete all files after 30 mins idle. if you want to keep them you need to buy a paid dyno. get it from here: https://www.heroku.com/pricing
Check why the product link does not contain the product id in HomeScreen.js and Product.js component. Your code seems right. clone this repo and run it on your computer. It works.
https://github.com/basir/amazona
Then compare your code with this.
make sure you did not return static data in data.js in server.js.
clone this repo and run it on your computer. It works.
https://github.com/basir/amazona
Then compare your code with this.
In this course, I only teach PayPal. for others you need to read the docs for node.js and react framework.
Did you use this command in this package.json? https://github.com/basir/amazona/blob/master/package.json#L9 and this in Procfile? https://github.com/basir/amazona/blob/master/Procfile#L1
To fix this issue we need to use a modal to show messages and user has to close it to continue. use this to wrap messages inside it: https://github.com/reactjs/react-modal
Follow these steps to fix this error:
1- Login with this seller account and in User Profile set a name for this seller.
2- Make sure you have a user with this id (product.seller._id) or not. if you deleted that user you need to delete the product too and create it again. make sure for current user you have set the seller name in User profile.
If it does not work you can simply clone the course repo:
https://github.com/basir/amazona
Then follow this guide to run it locally:
https://github.com/basir/amazona#run-locally
Then compare your code with this.
to fix validation error you need to check if you set the default value for isAdmin like this in userModal.js
https://github.com/basir/amazona/blob/master/backend/models/userModel.js#L8
and also try to set isAdmin: false in register API to fix this issue:
https://github.com/basir/amazona/blob/master/backend/routers/userRouter.js#L56
whether you did not set the google API key correctly or your google account on firebase is not verified.
check this please: https://developers.google.com/maps/documentation/javascript/error-messages
it means that user is null.
why user is null?
The user has been deleted. so you need to have a check like this:
{req.user? req.user.name:'Deleted User'}
or delete the order and create a new user and create order for them.
when you refresh the page at this address /cart/productid, then it adds productid to the cart again.
one simple solution is to move dispatch(addToCart(productId, qty)) from cart and product screen. so change ProductScreen.js:
const addToCartHandler = () => {
dispatch(addToCart(productId, 1)); // you need to import dispatch like in cart screen
props.history.push(`/cart`);
};
then remove this line from CartScreen.js: https://github.com/basir/amazona/blob/master/frontend/src/screens/CartScreen.js#L16-L18
you get proxy error if:
- you do not set proxy like this: https://github.com/basir/amazona/blob/e700bc418280f1bd48d2e7594ca315ec4f95202b/frontend/package.json#L3
- or there is an error in your backend code. check the terminal of backend and fix the issue.
first of all make sure you have this version of socket.io:
https://github.com/basir/amazona/blob/master/package.json#L30
the remove node engine part to use the latest node in the Heroku.
https://github.com/basir/amazona/blob/master/package.json#L37-L40
for not showing images:
-
make sure you have images in public folder like this: https://github.com/basir/amazona/tree/master/frontend/public/images
-
check image url on the screen (right click on image icon) and make sure it points to this address:
http://localhost:3000/images/p1.jpg
if they are ok then you should see images.
use this guide to make all images same size:
hello there,
Paytm is not part of this course but I found this video to interagte paytm with node apps:
https://www.youtube.com/watch?v=HQsKYj8OOGk
hello there,
yes, you are right. it is becaus of this:
https://github.com/basir/amazona/blob/master/backend/routers/productRouter.js#L150
you can change isAdmin with isSellerOrAdmin to fix it. but I don't recommend it because of security reasons