Hello! Here's a handy boilerplate to use when you need to quickly create a JSON api.
Steps:
- Create a free account at https://cloud.mongodb.com/ and create a cluster. The site will guide you through this.
- After the cluster has finished provisioning, copy the database URL (it will look something like mongodb+srv://fdkjfakdjf)
- Create a .env in the root directory, and add the line DB_URL=
- Run the command
npm i
in the root directory, and then runnpm run dev
. - In your browser, navigate to http://localhost:3000/api/foo, and you should see an empty array returned.
- To test the API's functionality, import the Postman json provided into the Postman app, and you'll have "get all", "get by field", and "upsert" requests available.