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

128
Vistas
Fetch - get HTML text as a response

I have a problem. I have rate-limit that returns HTML:

const Limiter = rateLimit({
  windowMs: 5 * 60 * 1000,
  message: "Too many requests created from this IP, please try again later.",
  max: 10
})

And I have fetch request in Client side that gets that Message:

      const body = { email, password }

      const res = await fetch("http://localhost:5000/api/auth/login", { 
        method: "POST",
        headers: {
          "Content-Type": "application/json"
        },
        body: JSON.stringify(body)
      })

      const parseRes = await res.json()

      if(parseRes.JwtToken) {
        localStorage.setItem("JwtToken", parseRes.JwtToken)

        setAuth(true)
        toast.success("Login successfuly")
      } else {
        setAuth(false)
        toast.error(parseRes)
      } 

My problem here is that when I get json object back it displays on the screen. But when I get that message object it does nothing. It just shows that failure 429 in the console. My question here is how can I get/display that HTML that returns normally like I would get an JSON object.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

So before you parse the JSON check the status

if (!res.ok) {
  /* handle the error */
  return;
}
const parseRes = await res.json()
about 4 years ago · Juan Pablo Isaza Denunciar
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