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

143
Vistas
Javascript JSON not parsing properly

I'm trying to get data out of a reply given to me from a backend API. I have an object called result which contains the following reply from the server:

{
  connection: 'Keep-Alive',
  'content-language': 'en-GB',
  'content-length': '0',
  'content-type': 'text/html'
  date: 'Fri, 11 Mar 2022 06:41:06 GMT',
  'keep-alive': 'timeout=5, max=100',
}

I'm trying to get the 'keep-alive' part but I'm unsure how I can access it.

I've tried parsing result as JSON

const obj = JSON.parse(result)
console.log(obj)

But this throws the following error:

undefined:1
[object Object]
 ^

SyntaxError: Unexpected token o in JSON at position 1

The issue seems to be that connection and date aren't within single quotes and I don't know how to fix this.

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