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

144
Views
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
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!