Questions tagged [mern]

Discover the remarkable acronym MERN, which abbreviates Mongo, Express, React, and NodeJS.

What are the steps involved in converting a MERN application into a desktop application?

As a beginner in front-end application development, I recently created a MERN application in React with separate frontend and backend parts. Everything is working smoothly, but now I want to convert it into a desktop application that can run independently ...

MERN Stack Application Error: Unable to set headers after they have already been sent to the client

Can someone help me with redirecting users after authentication based on their role using user.role? I am encountering the following error message: UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to t ...

What is the best way to logout and remove cookies once the jsonwebtoken has expired?

Seeking guidance on clearing a cookie after the 15-second lifetime of a JWT token. Is this task best accomplished on the server side or can it be managed on the client side? Code snippet with description provided below Utilizing mongoose, a user model is ...

Express.js does not recognize the req.query value

Incorporating Stripe Checkout functionality into a MERN application has been the focus of my recent project. Upon successful payment by a customer, they are directed to a checkout success URL where the CheckoutSuccess page is displayed. Additionally, Stri ...

Why am I seeing back-end console errors that are related to my front-end?

Recently, I encountered an error message that prevents me from using 'import' in my front end code when trying to execute 'node index'. This issue never occurred before, and it only arose when I returned to this project. In my backend ...

The issue I am facing involves a 404 not found axios error when attempting to send a post request

I am attempting to send data via a post request from react.js to express.js using axios, but I keep encountering a 404 not found axios error. You can view the error image here. Below is my code: export default function Upload() { const [state, setState ...

Request for removal in Express.js

Currently in the process of developing a MERN-stack app, but encountering issues with the delete request function. Here is the relevant code snippet: Upon attempting to send a delete request via Postman, an error message is displayed. I have researched ...

Issue with Heroku deployment: Express module not detected

I'm currently facing an issue while trying to deploy my Node.js app that includes some getter and setter functions. Despite selecting the Node.js environment on Heroku and providing all necessary environment variables, I keep encountering errors related to ...

When utilizing Javascript's Array.push method, a nested array is generated that is inaccessible using the index

I have reviewed several articles discussing the issue of asynchronous calls returning undefined. Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference Get data from fs.readFile However, none of these articles ...

I've been attempting to display information from a mongodb server onto my react application, but unfortunately, it's just not functioning as expected

Below is the error message from the console log: An Error was encountered: Objects are not valid as a React child (found: object with keys {_id, inputText, __v}). If you intended to render a collection of children, please use an array instead. at throwOnIn ...

Step-by-step guide for launching a Next.js/Node application

Currently, I am developing a full-stack project utilizing a next.js application for the front-end and a node/express server for the API. The front-end and back-end are running on separate ports. Here is how my application is configured: https://i.stack.im ...

Mern, Issue with Removing Comments

Having trouble deleting comments within a single post? I keep encountering a 404 Error and I'm not sure why the post is not being found. I really need some assistance in figuring out what's causing this issue and why I'm unable to delete a comment from a p ...

Is it possible to run both Express and React on the same port within the MERN Stack

Currently, I am working on a project that utilizes the MERN stack - MongoDB, Express, React, and Node. However, I have encountered an issue when attempting to post data from a form in a React component to an API endpoint defined in Node.js. Upon submission ...

problem encountered while attempting to transmit data to multer in React

I was attempting to upload an image to the backend using Multer. I have reviewed the backend code multiple times and it appears to be correct. Could there be an issue with my front-end code? Here is a POST code snippet: const response = await fetch('http: ...

Encountered an error: Unable to retrieve properties of an undefined value (reading '_id')

After logging in, I encounter a white page displaying the error ChatLogics.js:2 Uncaught TypeError: Cannot read properties of undefined (reading '_id'). Oddly enough, upon refreshing the page once, the error vanishes. Why is the _id undefined rig ...

"Proceeding without waiting for resolution from a Promise's `.then`

I am currently integrating Google Identity Services for login on my website. I am facing an issue where the .then function is being executed before the Promise returned by the async function is resolved. I have temporarily used setTimeout to manage this, b ...

Encountering an error message of "[jwt is not defined]" when attempting to retrieve data from the MongoDB

Explaining the question - I am successfully registering users in a mongoDB database and generating an accessToken [jwt based]. However, when trying to query the database to fetch the list of users, I encounter the error: jwt is not defined. Also, mentioni ...

Is there a way for me to adjust the typography background based on its current status?

Is there a way to dynamically adjust the background color of text based on the status value? Currently, when the status is pending, the background color defaults to yellow. For example, if the status changes to complete, I want the background color to ch ...

I'm having trouble getting my MERN app to run on Heroku. Any suggestions on how to resolve this issue?

I recently used Brad Traversys Guide to create a basic MERN Stack App with React.js, Redux.js, Node.js, Express.js, and MongoDB using create-react-app and Mlab. The app functions perfectly on my local server without any issues, but I am facing difficulties ...

What steps can be taken to fix the 'Error: Cannot GET /' issue on Localhost?

I'm having an issue with my Node.js Express project where I keep getting a 'Cannot GET /' error on Localhost. Below is the content of my server.js file: console.clear(); const express = require("express"); const app = express(); c ...

Encountering a 400 (Bad Request) error while making a POST request to the server in a MERN

In my reactjs application, I added a button to delete user accounts. When the button is clicked, a form appears where users need to enter their password and click on Delete to confirm. However, when testing this feature, clicking on the Delete button does ...

What could be the cause of this situation?

Recently, I started working on a MERN app using Express. While creating the server with Express, I encountered an error. const express = require("express"); const app = express(); const PATH = require("path"); const LAYOUT = require(&qu ...

Gradebook modeling is an essential aspect of educational management

Currently, I am in the process of designing the database for my MERN application (which employs Next.js in addition to React.js). The main purpose of my app is to serve as an LMS (Learning Management System) where educators can post assignments, tests, r ...

authorization for certain express routes using passport.js

Securing certain express routes with Passport.js authentication Steps for authenticating specific routes in Passport.js Looking for a method to authenticate particular routes using Passport.js Your assistance is greatly appreciated... ...

{ "error": "The 'title' property of 'req.body' cannot be destructured because it is not defined." }

Here are the snippets of code for a Node.js application: // src/models/workoutsModel.js const mongoose = require("mongoose"); const Schema = mongoose.Schema; const workoutSchema = new Schema({ title: { type: String, required: true, ...

Issues encountered while running MERN tests

After exploring the MERN framework for a new project, I have encountered some discouraging issues. Following the setup instructions using mern-cli, the project is created and runs correctly. However, when trying to execute... npm run test The following e ...

Every time I attempt to access a product from the HomeScreen, I encounter the following issue: "Converting circular structure to JSON"

Whenever I try to click on a product from the HomeScreen.js, it is supposed to take me to the ProductScreen in order to display the detailed information of the product. However, I encountered the following error message: Converting circular structure to J ...

What is the method for linking the ReactJS frontend socket client with the server-side socket?

I encountered the following issue while running my MERN app: WebSocket connection to 'ws://localhost:3000/socket.io/?EIO=4&transport=websocket' failed: WebSocket is closed before the connection is established. I am unsure of how to establish ...

Warning: Attempting to destructure the property 'name' from 'req.body', which is undefined, is causing a TypeError

Currently, I am diving into the world of MERN Stack web development and running into a unique issue. When using Postmate to input data from the body to the database, everything works smoothly when done from the server.js file. However, when attempting the ...

Socket.on seems to be malfunctioning

Currently, I am in the process of creating a message board for practice purposes and have successfully implemented notifications and a chat application using socket.io. My next goal is to add basic video call functionality, but I have encountered some dif ...

What are the steps to developing a chat application with MERN stack or another straightforward method?

What is the best way to develop a chat application for direct communication between two individuals? For instance, imagine a website with numerous producers where a consumer wishes to engage in a live chat with a specific producer. Any ideas on how to ach ...

What is preventing me from making a call to localhost:5000 from localhost:3000 using axios in React?

I have a React application running on localhost:3000. Within this app, I am making a GET request using axios to http://localhost:5000/fblogin. const Login = () => { const options = { method: "GET", url: "http://localhost:5000/fblogin", ...

What is the most efficient way to toggle boolean values in a JSON object using Express?

After completing my first MERN CRUD app as a beginner, which is a todo list with a complete button that scores out items, I am looking for ways to enhance it. Currently, when the complete button is clicked, a post request is sent to the nodejs/express ba ...

Steps to Embed an Image File in a MERN Stack Application

I'm attempting to load an image from a file inline because I need to pass data (the image name), but nothing seems to be working. It doesn't work whether the image is inside the src folder or outside in the public folder. Here's what I tried recently: < ...

Error: Unable to access 'name' property in reactjs due to undefined value

Here is the frontend code snippet: { (opp||[]).map(opps=>{ return( <div className="card OppCard"> <div className="card-body" > <h4>{opps.title}</h4> <p><b&g ...

Tips for resolving validation errors when adding to MongoDB in a MERN application

Currently, I am in the process of mastering the MERN stack by developing a straightforward shopping list application. My API is set up to handle GET, POST, and DELETE requests successfully, as confirmed through Postman testing. Locally, I can retrieve it ...

We are encountering an issue in Node.js with Mongoose where an instance of TypeError is being received instead of the required string type for the "path" argument

An Error Occurred Connection Successful, Port 4000 Listing Form node:internal/errors:464 ErrorCaptureStackTrace(err); ^ TypeError [ERR_INVALID_ARG_TYPE]: The argument for "path" must be a string. Instead, received a TypeError instance. at new NodeError ...

Strategies for efficiently handling time in React and Node.js without being impacted by timezone issues

Despite exhausting all methods to assess time in my mern application, I have yet to find a solution. My search online has also been fruitless... ...

There was an issue encountered while attempting to add concurrently to the package.json

Bundle of scripts in package.json "scripts": { "begin": "node back-end/server.js", "serve": "nodemon back-end/server.js", "client-initiate": "npm start --prefix front-end", ...

The attempt to add a note with a POST request to the /api/notes/addnote endpoint resulted in a

I'm facing an issue while trying to send a POST request to the /api/notes/addnote endpoint. The server is returning a 404 Not Found error. I have checked the backend code and made sure that the endpoint is correctly defined. Here are the specifics of ...

What is the best way to combine a React App and an Express App in order to deploy them as one

After successfully creating an Express and MongoDB API and connecting it to my React Application, I encountered a situation during deployment. It seems that I need to deploy both projects separately, which means I would need two hosting plans for them. H ...

What is the best way to modify an array within separate functions in a NodeJS environment?

I am facing an issue where I want to update an object inside the fetchAll() functions and then send it back after successful updation. However, the response I receive is '[]'. var ans = [] Country.fetchAll(newdate,(err, data) => { if (err) ...

Troubleshooting: Issue with reloading in MERN setup on Heroku

I successfully deployed my MERN stack application on Heroku using the following code: import express from "express"; import path from "path"; const app = express(); const port = process.env.PORT || 5000; app.get("/health-check&qu ...

What are the reasons behind the difficulty in deploying my Vite app on Vercel?

Currently, I am working on developing a social media app with Vite. However, I am facing challenges when trying to deploy it. I have included my vite.config.js file below for better insight into the issue at hand. The main issue is that while the ./ route ...

MERN application encounters error with running "heroku-postbuild" script during deployment on Heroku platform

During the process of deploying my app to Heroku, everything seems to be running smoothly until I encounter an issue. After logging in, I execute a series of terminal commands for deployment and receive the following responses: heroku login heroku: Press a ...

How come I am receiving the E11000 error from Mongo when I have not designated any field as unique?

Encountering an issue while attempting to save the second document to MongoDB Atlas. The error message reads as follows: Error:MongoError: E11000 duplicate key error collection: test.orders index: orderId_1 dup key: { orderId: null } Despite having no un ...

Following deployment and page building in REACT JS, the pages fail to open

As a student still learning, I'm in need of assistance with a project. When I deploy the system and run the build, the initial page works fine but all redirects fail to work. If you'd like to view the page, it's available at: I'm seei ...

What sets apart the following: ( import React from "react"; ) and ( import React from 'react'; )?

When it comes to imports, is there a distinction between using single quotes (') versus double quotes ("), for example in import React from 'react'; and import React from "react";? Are there any notable differences? ...

The issue with fetching user profile data on the client-side in Next.js 14

I've run into a problem with client-side data fetching on my Next.js 14 project. More specifically, I'm trying to retrieve user profile information from a backend API using Axios within a component, but for some reason, the data isn't coming ...

Checking out a mongodb record by object identification

I've been building an inventory system using the MERN stack. However, when I attempt to view products with the code below, it always returns 'No Matching Product' even though there are matching products in my collection. The backend works fine when tested ...

How can ExpressJS be used to direct users to individual standalone React applications?

I've spent a lot of time scouring the internet for a solution to my problem, but it seems like maybe I'm not asking in the right way. My project involves creating a Node-Express website where ReactJS is only needed on specific pages, while the rest are se ...

What is the best way to send an object array from an express function to be displayed on the frontend?

//search.js file import axios from "axios"; export function storeInput(input, callback) { //input = document.getElementById("a").value; let result = []; console.log(input); if (!callback) return; axios.post("ht ...

encountering a 404 error while attempting to access the signin route on Heroku

After deploying my MERN app on Heroku, I encountered a 404 page error when trying to access specific routes by entering their URLs directly. The navbar links function correctly and lead me to the sign-in and sign-up pages without any issue. However, clicki ...

"Revolutionizing online payments with Material UI's dynamic payment

Struggling with creating dynamic material UI payment elements, I wanted to share how I successfully achieved this. You can access the code for these elements on the material UI website. https://i.stack.imgur.com/kYewa.png Below is an example of static da ...

Updating the Navigation Bar after User Logs in

In the process of working on my assignment, I am in the midst of developing a web application. As someone who is new to using React, I'm currently trying to figure out how to modify my navbar once a user has logged in. For instance: Prior to logging ...

Troubleshooting: How to resolve the issue of "Error [ERR_HTTP_HEADERS_SENT]: Unable to set headers after they have been sent to the client"

* **> const PORT=8000 const express = require('express') const {v4:uuidv4}=require('uuid') const bcrypt =require('bcrypt') const jwt =require('jsonwebtoken') const cors=require('cors') const {MongoClie ...

Best practices for effectively managing errors within JSON web tokens

I am a novice attempting to manage JWT verification. Within the function below, my goal is for the system to generate a new access token based on the refresh token if the user's access token has expired. import { asyncHandler } from "../utils/asy ...

When you try to install @mui/material, it may cause a conflict with

I'm encountering an issue while trying to set up @mui/material npm install @mui/material However, during the installation process, I am getting this error message: npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ...

Express API on Node.js fails to read Post request JSON data as null

Currently, I am in the process of developing an application utilizing the Mern stack. One of the recent tasks I have accomplished is sending a POST request from the React frontend to the endpoint using Axios. The snippet provided below showcases the code f ...

Troubleshooting: SwipeableDrawer's edge swipe feature is not visible on Material UI

Looking to incorporate Swipeable edge into a SwipeableDrawer: Browse the example here The intention is for the edge to remain visible even when the drawer is closed, allowing users to click on it and slide the drawer open. However, in my application, t ...

React js axios encountering CORS error while functioning perfectly in postman

I am encountering an issue in my Mern Stack Project where I can successfully create a Lesson using Postman, but when trying from my browser, I get a 500 error in the network tab. The console displays CORS error and another 500 error. I have tried various s ...

What is the best way to automatically launch my MERN application upon startup?

My friends and I recently launched a small startup and I developed a customized todo app for our team. I wanted to avoid the costs and challenges of uploading the application online, so I came up with an idea. What if I could replicate the project on all ...

Struggling to pass front end form data to the backend API in a React and Express.js application?

I am experiencing some issues with saving data from a React form. In the backend, I can only save the auto-generated ID from Mongoose. The API is not saving email and password in the database, as when I log the request body in the server it shows an empty ...

Is it time to swap out "localhost" with the service name in Docker?

I have successfully dockerized my reactjs app and express app. Check out the docker-compose.yml file I used: version: "3" services: client: image: react-app build: ./client ports: - "3000:3000" volumes: ...

Tips for storing information in MongoDb alongside an image

I am trying to store details in MongoDB and upload images to an "images" folder using Multer, but I am facing issues with retrieving the data on the server-side. const onSubmit = async (object) => { const fd = new FormData() fd.append('n ...

Transform the React.js class poll component into a React Hooks poll component

I have created a React component "class" based poll, but I am looking to convert it into a React hook form. Can someone please help me with this? I'm having trouble understanding how to achieve this. import React, { Component } from "react"; im ...

What could be causing the error message 'Please activate javascript' to appear in my React.js application?

I encountered the you need to enable javascript to run this app error in my MERN stack application. Every aspect works well except for an API call made for a specific route. I utilize the axios package and all API calls within the application successfully ...

Designing a dinner scheduler using React (MERN stack), looking to repurpose a module for inputting and modifying meals

In the process of developing a meal planning application, I am faced with the challenge of utilizing the same modal component for both adding and editing meals. The modal contains fields for name, ingredients, and the day of the week for meal preparation. ...

Cross-origin resource sharing (CORS) policy issue arises when the 'Access-Control-Allow-Origin' header is not included in the requested resource, especially when utilizing an iframe in a React

I am trying to link a website to a button using an iframe. This website allows access to all domain names. Below is the code for my button: <Button component={NavLink} activeClassName={classes.activeBtn} to="/searchEngine&qu ...

Still awaiting the signal from WDS for the update on the React app

Yesterday marked the beginning of my journey learning react. I initiated a new react app by executing the command npx create-react-app firstapp. Upon opening the console in my Firefox browser, I noticed the message: [HMR] Waiting for update signal from ...

Implementing ExpressJS with MongoDB on a MERN Development Stack

After configuring my ExpressJS & MongoDB client and running Nodemon, I consistently encounter the following warning: "DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the ...

Create a separate socket io connection for each individual user

I have integrated socket io into my MERN stack application to facilitate communication between the client and server. Essentially, I am monitoring changes in my mongodb cluster and sending those updates to the client using the socketio emit function. Howev ...

Strategies for resolving the issue of undefined req.body.password in express.js

Hello everyone, I am currently in the process of building an API using EXPRESS.JS and MongoDB. While testing with postman, I encountered an issue where the req.body.password field is undefined when attempting to parse it using postman. Strangely enough, I ...

Mastering the Art of Extracting HTML Text from JSON Files

I'm facing an issue in my react app where I can't read the HTML tags used in the content of a JSON file. Here's a snippet of the JSON file: [{ "_id": 9, "title":"Text 9", "subheader":"Dummy header 9", "images": "images/ ...

Server connection failure: MongoDB is unable to establish a connection

UPDATE: After attempting different ports, terminating tasks on ports, and trying again, I am still unable to connect. Today, I embarked on a tutorial for the MERN stack but unfortunately, I am unable to establish a connection to the server. Upon using npm ...