This project demonstrates a basic Node.js server with an endpoint "/api/users" that connects to a MongoDB database and returns a JSON list of all users. The MongoDB database contains a collection named 'users' with fields such as 'name', 'email', and 'age'.
-
Install Node.js and npm if not already installed.
-
Clone the repository:
git clone https://github.com/your-username/your-node-mongo-project.git
-
Navigate to the project directory:
cd your-node-mongo-project
-
Install dependencies:
npm install
-
Start the server:
node server.js
-
Access the list of users by visiting http://localhost:3000/api/users in your browser or through API tools like curl or Postman.
/api/users
: Retrieve a JSON list of all users from the MongoDB 'users' collection.