Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Commit 0326e07

Browse files
committed
fixed env config
1 parent 5042a8b commit 0326e07

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/routes/connect.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Connects to MongoDB
2-
// Only need one client instance
32

43
const { MongoClient, ServerApiVersion } = require("mongodb");
4+
require("dotenv").config()
55
const USER = process.env.DBUSER;
66
const PSWD = process.env.DBPASS;
77
const HOST = process.env.DBHOST;
@@ -32,6 +32,7 @@ async function run() {
3232
await client.close();
3333
}
3434
}
35+
3536
run().catch(console.dir);
3637

3738
export default client;

src/routes/serverProps.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import client from "./connect";
12

23
export const getServerSideProps = (async () => {
3-
const response = await fetch("")
4-
const pageData = await response.json()
4+
await client.connect();
5+
const response = await client.findOne();
6+
const pageData = await response.json();
7+
await client.close();
58

69
return {
710
props: {

0 commit comments

Comments
 (0)