Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

262
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda