Skip to content

Commit

Permalink
create the directory and the endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
amandhawb committed Jun 20, 2023
1 parent 9f86124 commit 45a1075
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Empty file removed database/api/test-api.js
Empty file.
2 changes: 1 addition & 1 deletion database/mongodb.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MongoClient } from 'mongodb'

if (!process.env.MONGODB_URI) {
throw new Error('Invalid/Missing environment variable: "MONGODB_URI')
throw new Error('Invalid/Missing environment variable: MONGODB_URI!!')
}

const uri = process.env.MONGODB_URI
Expand Down
18 changes: 18 additions & 0 deletions pages/api/members.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import clientPromise from "../../database/mongodb";

export default async (req, res) => {
try {
const client = await clientPromise;

const db = client.db("latinasdev");

const members = await db
.collection("members")
.find({})
.toArray();

res.json(members)
} catch (e) {
console.log(e);
}
}

0 comments on commit 45a1075

Please sign in to comment.