A full-stack application to track your inventory.
This project is a full-stack web application that allows users to manage an inventory of products, particularly sauces. The backend is built with Express.js server and communicates with the frontend created in React.
- Install all the required packages using
npm install
. - Populate the database with initial data using
npm run seed
. - Start the Express server with
npm run server-dev
. - Open another terminal and start the React development server with
npm run client-dev
.
Below are some of the common errors you might encounter while working on the inventory-app
along with troubleshooting steps:
- Error: Sequelize connection error.
- Cause: The database is not running or
.env
file is not set up correctly with the correct database credentials. - Solution: Ensure that the database service is running and that the
.env
file contains the correct database URL.
- Error:
Error: Cannot find module 'xyz'
wherexyz
is a module. - Cause: Dependency not installed or an incorrect import statement.
- Solution: Run
npm install
to ensure all dependencies are installed. Check the import statement for typos.
- Error: Cross-Origin Resource Sharing (CORS) errors in the browser's console.
- Cause: The frontend makes requests to a domain different from the one served by the backend.
- Solution: Ensure
cors
middleware is included and configured correctly inserver/app.js
.
If an API call to a non-existing route is made, you will encounter an error:
- Error:
404 - Not Found
- Cause: The client made a request to an endpoint that does not exist.
- Solution: Check the fetch URL in the React component and verify that it matches a defined route in
server/routes/index.js
.
- Error: Network request failed or similar errors in the console when making a fetch call from the React component.
- Cause: API server is not running or the endpoint is incorrect.
- Solution: Ensure the API server is running (
npm run server-dev
). Check the endpoint in thefetchSauces
function within theApp.js
component.
For contributing to this project, please follow the next steps:
- Fork the repository.
- Create a new branch for your feature.
- Commit changes to the branch.
- Push the branch to GitHub.
- Submit a pull request to the main branch.