Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

261
Views
fetch request is not working while using react js and express js, Unhandled Rejection (TypeError): Failed to fetch

I am using react js and express js program. I have created express server, however my react js app is not working with my express js. I am showing you codes of react js below

import React, { useEffect, useState } from 'react';

const Get = () => {
  
  const [users, setUsers] = useState([])

  useEffect(() => {
    fetch("http://localhost:3000/posts")
        .then((response) => response.json())
        .then((users) => {
            setUsers(users);
        })
  }, []);

  return (
    <>
      {users.map((post) => {
        return (
          <div>
            <p>{post.date}</p>
          </div>
        )
      })}
    </>
  )
}

export default Get

It says

Unhandled Rejection (TypeError): Failed to fetch

and I think that it is connected with my fetch request.

This is the information in my server:

[
  {"_id":"617fa514d55c0cced18b1f6b","title":"New Title","description":"Hello World","date":"2021-11-01T08:26:52.000Z","__v":0},
  {"_id":"617fa52bd55c0cced18b1f6d","title":"New Title","description":"Hello World","date":"2021-11-01T08:26:52.000Z","__v":0},
  {"_id":"617fa52cd55c0cced18b1f6f","title":"New Title","description":"Hello World","date":"2021-11-01T08:26:52.000Z","__v":0}
]
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!