The signup controller encountered a malfunction with illegal arguments: an undefined value and a string

I recently started learning MERN through a tutorial and encountered an issue with my database. I have successfully created a function to send data to the database, but for some reason, I can't see the data in the database. Below is the code snippet:

export const signup = async (req, res) => {
    try {
        // code logic here
    } catch (error) {
        console.log("Error in signup controller", error.message);
        res.status(500).json({ error: "Internal Server Error" });
    }
}

When attempting to access /api/auth/signup, I am receiving the following message:

cannot GET /api/auth/signup

I am considering whether this issue is due to using a POST request instead of a GET request. Additionally, when I attempt to send the data, I encounter the following error:

Error in signup controller Illegal arguments: undefined, string

At this point, I'm unsure how to proceed. Any advice would be greatly appreciated.

Answer №1

Make sure to include body-parser in your project

npm install body-parser

Next, integrate it into your express setup

express.use(bodyParser.urlencoded({extended: true}));
const router = express.Router();

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The issue arises with AJAX functionality not functioning properly when the checkbox is left unchecked

I want to update the flag value in my database every time I check or uncheck a checkbox. However, for some reason, the AJAX call only triggers when changing the checkbox from checked to unchecked. HTML <table id="example" class="display" cellspacing= ...

Is it possible in MongoDB to search for a dataset repeatedly based on their child values?

Currently, I am in the process of developing a social calendar application and one of the features I want to implement is recurring events. After much consideration, I have decided to use the following schema as I believe it will be the most memory-efficie ...

Share the name of the Quasar component with the Vue 3 render function

I'm struggling to dynamically create a Vue 3 app with different components specified by name, such as "div", "button", or Quasar's "q-btn". When I try to pass the latter to Vue's render function Vue.h, I encounter difficulties. <html> ...

Display information from an array in checkboxes. If the same data appears in another array, the corresponding checkbox in React will be automatically checked

I currently have two arrays. The first array, let's call it arr1, contains multiple objects such as [{"Name":"Mr.X"},{"Name":"Mr.Y"},{"Name":"Mr.Z"}]. The second array, named arr2, holds a few values like [{"Name":"Mr.Z"}]. My goal is to display all ...

Issues with applying styles to custom components in styled-components

I attempted to customize the inner elements of react-id-swiper using the code below: import Swiper from 'react-id-swiper'; import styled from 'styled-components'; const MySwiper = ({ className, children }) => ( <Swip ...

What is preventing $scope.$watch from functioning in AngularJS?

I'm struggling to get a $watch function to monitor changes in $scope.data. Here's the code I've been working with: [http://jsbin.com/biqesojaqu/1/edit?html,js,console,output][1] app.html <!DOCTYPE html> <html> <head> < ...

What is the best way to encapsulate multiple Bluebird promises within a single promise?

Seeking assistance in creating an async wrapper for a redis query supported by a db query. If the redis query fails, I want to execute the db query instead. When the db query is successful, I aim to store the returned data in redis before sending it back. ...

Converting a JSON object that is created dynamically to XML in node.js

Is there a way to convert a dynamically created JSON object into XML using node.js? I am tasked with generating JSON objects dynamically based on available data, which includes nested lists of objects. var Obj = { root: { Door_Keeper: { ...

Instructions for establishing VPC network peering between various App Engine projects and Mongo Atlas

A while back, I developed an App Engine app that securely connects to Mongo Atlas through a network peering connection. Everything was running smoothly until I decided to expand the app to be multi-region. This required creating multiple projects and repli ...

How can you apply a class to a different element by hovering over one element?

Is there a way to darken the rest of the page when a user hovers over the menu bar on my website? I've been playing around with jQuery but can't seem to get it right. Any suggestions? I'm looking to add a class '.darken' to #conte ...

Sending DOM values to React components as properties

Forgive me if this question seems basic, as I am still learning ReactJs. I have a react component that displays the user's sign-in status: <AccountStatus iconsize="medium" activate={[true,false,true]}/> Image 1 //or using <AccountStatus i ...

The issue with Mongoose's nested populate feature not functioning properly with Q

As I delve into promises, I am experimenting with optimizing my nested populates by utilizing Q library. The issue at hand is that the layers are not executing in the intended order, leading to data not being passed through to subsequent layers effectivel ...

What is the most efficient way to handle dependencies and instantiate objects just once in JavaScript?

I am interested in discovering reliable and tested design patterns in Javascript that ensure the loading of dependencies only once, as well as instantiating an object only once within the DOM. Specifically, I have the following scenario: // Block A in th ...

"ReactJS error: Unable to upload file due to a 400

Every time I attempt to upload a file, I encounter this error: "Uncaught (in promise) Error: Request failed with status code 404". I'm puzzled as to why this is happening. Here's the section of my code that seems to be causing the issue. ...

Generating a tally from JSON feedback using JavaScript

I'm looking to extract valuable data from a JSON obtained from web services that doesn't contain the required information. The JSON output resembles the following: [ { "Val1": "Value One", "Status": "Okay", "endDate": "2017-09-30T00:00: ...

Creating a top-to-bottom pull effect on a single page, similar to the Android title bar, can be achieved using CSS3

Is there a way to achieve an effect in HTML that resembles the pull title bar animation from top to bottom in Android? Any suggestions on how to create this effect or what tools I would need? Currently, when I swipe, the page simply displays a following ...

Achieving CommonJS imports compilation with Typescript

In my TS file, I've included a 3rd party package using import XXX { YYY, ABC, 123 } from 'XXX'; While it compiles to CommonJS without any issues, I'd prefer to have it compiled to an ESModule instead. I tried changing the target and mo ...

Issues with displaying AngularJs directive template

Having an issue with my AngularJs directive. Everything works perfectly fine when I use the "template" attribute, but when I switch to using "templateURL", it stops working. Both the JavaScript file for the directive and the HTML file for the template are ...

MongooseError: The operation `users.findOne()` has encountered an issue

While working on my movie website, I encountered an issue when setting up the login feature. When trying to register using POST through Insomnia, I received an error message stating "MongooseError: Operation users.findOne() buffering timed out after 10000m ...

Reacting with Node.js: Capturing a selected option from a dropdown menu and storing it in the database

On my React frontend, I have a select dropdown like this: <select name="level" value={level} onChange={this.handleChange} className="form-control"> <option>Begineer</option> <option>Intermediate</option> <option> ...