title: My data is not fetching post route in node
body: <p>I'm a bit confused with my little project.
  I've made a route in node:</p>
  <pre><code>router.post('/signup', userController.signUp);
  </code></pre>
  <p>here's the controller for signup:</p>
  <pre><code>const signUp = async (req, res, next) =&gt; {
  
  const {name, email, password} = req.body;
  
  // check if user already exists
  let existingUser;
  try{
      existingUser = await User.findOne({email});
  } catch (e){
      const error = new HttpError('Signup up failed, please try again later', 500);
      return next(error);
  }
  
  if (existingUser){
      const error = new HttpError('User already exists, please login instead', 422);
      return next(error);
  }
  
  // hash password
  let hashedPassword;
  try{
      hashedPassword = await bcrypt.hash(password, 12);
  } catch (e){
      const error = new HttpError('Could not crate user, please try again', 500);
      return next(error);
  }
  
  // create new user
  const createdUser = new User({
      name,
      email,
      password: hashedPassword
  })
  
  // save new user
  try {
      await createdUser.save();
  } catch (e){
      const error = new HttpError('Signing up failed, please try again.', 500);
      return next(error);
  }
  
  // generate token
  let token;
  try {
      token = jwt.sign({
          userID: createdUser.id,
          email: createdUser.email
      }, 'supersecret_dont_share', {expiresIn: '1h'});
  } catch (e) {
      const error = new HttpError('Signing up failed, please try again.', 500);
      return next(error);
  }
  
  // send response
  res.status(201).json({user: createdUser.id, email: createdUser.email, token });
  
  }
  </code></pre>
  <p>I'm trying to create a user from the front end:</p>
  <pre><code>const getUsers = async (e) =&gt; {
  
     e.preventDefault();
  
          const data = {
              &quot;name&quot;: &quot;testttt&quot;,
              &quot;password&quot;: &quot;testtt2&quot;,
              &quot;email&quot;: &quot;test@das.com&quot;
          }
          const response = await fetch('http://localhost:5000/users/signup', {
              method: 'POST',
              body: JSON.stringify(data)
          });
      console.log(response)
  
      return response.json(); 
      }
  </code></pre>
  <p>And I got this:</p>
  <p><a href="https://i.stack.imgur.com/bTMHM.png" rel="nofollow noreferrer">https://i.stack.imgur.com/bTMHM.png</a></p>
  <p>also I use in <code>app.js</code> (server):</p>
  <pre><code>app.use(bodyParser.json());
  
  // cors headers
  app.use( (req, res, next) =&gt; {
      res.setHeader('Access-Control-Allow-Origin', '*');
      res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content Type, Accept, Authorization');
      res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PATCH, DELETE');
      next();
  } );
  
  // routes
  app.use('/users', userRoutes);
  </code></pre>
  <p>The problem is that I cannot create a new user, when I console log <code>req.body</code> in controller, it shows me an empty object, but when I'm trying to create a user from postman it works.</p>
  <p>Can someone please help me?</p>