My image is stored in the server folder and my react app folder is food
I wanted to call images from server(server>uploads>foods) folder to food(food>src>home). I was used back path like as (../) but it doesn't work.
So, how I can call images from the server folder to the food folder in react
How can I call image from outer folder of my react-app folder in react.js
I assume, you have to fetch image from server folder, which is your express.js application.
The images, CSS files, JavaScript files, and other files that the client downloads from the server are known as static files. These static files can be fetched with the use of the express framework and without the use of it.
you may have following directory tree:
Using the Express framework: Using the express framework its built-in middleware function express.static() can be used to serve static files.
Filename: server.js
Steps to run the program:
Now you can access image from following url: