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

137
Vistas
Filter data pulled from API to only read specific values

I am pulling all customer information via an API and printing it in the console.

I am doing this with

 if (this.readyState === 4) {
    console.log('Body:', this.responseText);
 }
};

which gives all of the following data (changed for obvious reasons)

{"id":2,"userIdent":"11","randomInfo":null,"isLead":false,"clientType":1,"companyName":null,"companyRegistrationNumber":null,"companyTaxId":null,"companyWebsite":null,"street1":"1234 Happy Rd","street2":null,"city":"Smile City","countryId":249,"stateId":22,"zipCode":"12345","fullAddress":"1234 Happy Rd, Smile City, MI","invoiceStreet1":null,"invoiceStreet2":null,"invoiceCity":null,"invoiceStateId":null,"invoiceCountryId":null,"invoiceZipCode":null,"invoiceAddressSameAsContact":true,"note":null,"sendInvoiceByPost":null,"invoiceMaturityDays":null,"stopServiceDue":null,"stopServiceDueDays":null,"organizationId":2,"tax1Id":null,"tax2Id":null,"tax3Id":null,"registrationDate":"2022-03-07T00:00:00-0500","leadConvertedAt":null,"companyContactFirstName":null,"companyContactLastName":null,"isActive":false,"firstName":"boop":[],"accountBalance":0.0,"accountCredit":0.0,"accountOutstanding":0.0,"currencyCode":"USD","organizationName":"My Company","bankAccounts":[],"tags":[],"invitationEmailSentDate":null,"avatarColor":"#ef6c00","addressGpsLat":11.22,"addressGpsLon":-22.11,"isArchived":false,"generateProformaInvoices":null,"usesProforma":false,"hasOverdueInvoice":false,"hasOutage":true,"hasSuspendedService":false,"hasServiceWithoutDevices":false,"referral":null}

I only want to pull the value associated with, for example, "userIdent" which would be 11, but I'm not sure how to do this when I'm pulling the data from the api.

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

0

const { userIdent } = JSON.parse(this.responseText)
console.log(userIdent) // "11"
about 4 years ago · Juan Pablo Isaza Denunciar

0

You need to add this

var data = JSON.parse(this.responseText);
var userIdent = data['userIdent'];
console.log(userIdent);
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