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

179
Views
How can I read json data which has its tag/identifier in quotes?

I'm using NodeJS to fetch the NPM registry with the code below.

import fetch from "node-fetch";

let url = "https://registry.npmjs.com/[package-name]";

let settings = { method: "Get" };

fetch(url, settings)
    .then(res => res.json())
    .then((json) => {
    console.log(json.versions)
    });

So, the response that I get in my result is:

{
  _id: '123456789',
  name: 'package-name',
  'dist-tags': { latest: '2.0.0' },
  versions: {
    '2.0.0': '...'
}
...
}

I am trying to read the 'versions' section, but the issue I have is that the version number 2.0.0 is encased in quotes and it might change but I want to find that value. How can I read it?

Thanks in advance, and let me know any other info I missed.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You'll have to check if the versions has the key you want.

if(Object.keys(response.versions).includes('2.0.0')){
  // response.versions['2.0.0'] exists
}

Or you could iterate through Object.keys(response.versions) and handle each version entry as you wish.

about 4 years ago · Juan Pablo Isaza Report
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!