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

175
Vistas
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 Respuestas
Responde la pregunta

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 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