Home > Mobile >  Error Connection Reset error in mern stack project
Error Connection Reset error in mern stack project

Time:04-28

I follow the JavaScript Mastery video for the CRUD app. I have a problem connecting the frontend with the backend. When I try to submit the form, I console log it. It shows the

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

I checked the server and database connections, and there is nothing wrong.

Error Screenshot

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);

CodePudding user response:

The error is coming from one of your extensions not from your code. Whatruns to be specific. self.processResponse is not a function #33355

  • Related