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

135
Views
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 answers
Answer question

0

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

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