mern栈项目中的Error Connection Reset错误

Error Connection Reset error in mern stack project

我关注了 CRUD 应用程序的 JavaScript Mastery 视频。我在连接前端和后端时遇到问题。当我尝试提交表单时,我 console log 它。它显示了

POST http://localhost:5000/posts net::ERR_CONNECTION_RESET

我检查了服务器和数据库连接,没有问题。

错误截图

index.js

import axios from 'axios';

const url = 'http://localhost:5000/posts';
export const fetchPosts = () => axios.get(url)
export const createPost = (newPost) => axios.post(url, newPost);

server/index.js

import express from "express";
import bodyParser from "body-parser";
import mongoose from "mongoose";
import cors from "cors";
import postRoutes from './routes/posts.js';

const app = express();

app.use(bodyParser.json({limit: "30mb", extended: true}));
app.use(bodyParser.urlencoded({limit: "30mb", extended: true}));
app.use(cors());
app.use('/posts', postRoutes)

const CONNECTION_URL = "mongodb+srv://mominriyadh:@######@cluster0.jqiet.mongodb.net/myFirstDatabase?retryWrites=true&w=majority";
const PORT = process.env.PORT || 5000;

mongoose.connect(CONNECTION_URL, {useNewUrlParser: true, useUnifiedTopology: true})
    .then(() => app.listen(PORT, () => console.log(`server running on port: ${PORT}`)))
    .catch((error) => console.log(error.message));

mongoose.set('useFindAndModify', false);

错误来自您的扩展程序之一,而不是您的代码。具体是什么。 self.processResponse is not a function #33355