Archived
.
This commit is contained in:
1 parent
6abb6530bd
commit
683b228666
4 files changed
+2264
-30
No files matched your search
+15
-16
@@ -1,7 +1,6 @@
|
||||
|
||||
const express = require('express')
|
||||
const app = express()
|
||||
const port = process.env.PORT || 3000
|
||||
const express = require("express");
|
||||
const app = express();
|
||||
const port = process.env.PORT || 3000;
|
||||
const { MONGO_URI } = require("./config");
|
||||
const mongoose = require("mongoose");
|
||||
const events = require("./models/events");
|
||||
@@ -12,17 +11,17 @@ mongoose
|
||||
})
|
||||
.then(() => console.log("connected"))
|
||||
.catch((err) => console.log(err));
|
||||
app.get('/', async (req, res) => {
|
||||
try {
|
||||
const event = await events.find({ mess : "one" });
|
||||
if (!event) throw Error("something went wrong");
|
||||
console.log(event)
|
||||
res.status(200).json(event);
|
||||
} catch (err) {
|
||||
res.status(400).json({ msg: err });
|
||||
}
|
||||
})
|
||||
app.get("/api", async (req, res) => {
|
||||
try {
|
||||
const event = await events.find({ mess: "one" });
|
||||
if (!event) throw Error("something went wrong");
|
||||
console.log(event);
|
||||
res.status(200).json(event);
|
||||
} catch (err) {
|
||||
res.status(400).json({ msg: err });
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Example app listening at http://localhost:${port}`)
|
||||
})
|
||||
console.log(`Example app listening at http://localhost:${port}`);
|
||||
});
|
||||
Reference in new issue
Block a user