ในขณะที่กำลังเช็คข้อ endpoint ใช้โพสต์วิธีการอยู่ในบุรุษไปรษณีย์มีข้อผิดพลาด
.ซองแฟ้มกับพอร์ต,MONGO_URI และ mongoose การเชื่อมต่อจะถูกตั้งขึ้นอย่างเหมาะสมและกำลังกอไม่มีข้อผิดพลาด
รหัสในของฉัน app.js
const express = require('express')
require('./db/db')
const dotenv = require('dotenv')
const app = express()
const mongoose = require('mongoose')
dotenv.config({ path: 'config.env' })
const PORT = process.env.PORT
const User = require('./model/user')
app.get('/', (req,res)=>{
res.send('Hello')
})
app.post('/create-user', async(req, res)=>{
const user = await User({
fullname: 'John5 Doe',
email:'[email protected]',
password:'12345'
});
await user.save();
res.json(user);
})
app.listen(PORT, () =>{
console.log(`app is running on port ${PORT}`)
})
แต่ข้อมูลมันไม่ช่วยใน MongoDB กฐานข้อมูลเหมือนกัน เท่าที่ผมตรวจ endpoint ในบุรุษไปรษณีย์และปรับปรุงคลังสื่ออยู่ใน mongo db มันเป็นการแสดงหน้าเว็บนี้
ยังไงฉันซ่อมได้??