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

99
Views
How to pull certain field names from a REST API using ExpressJS and Axios

So I have a set of code that can pull the whole external API with this code:

//endpoint that will fetch data from an external API
app.get("/externalapi", (req, res) => {
    
    let apiURL = 'https://herokuapp.com/api/v1/data';
      
      axios.get(apiURL)
          .then(response => {
              
              res.status(200).json(response.data);
          })
          .catch((err) => {
              res.status(500).json({ message: err });
          });
  });

Part of the data that is generated via Postman is this (used as an example):

{
    "data": [
        {
            "first_name": "Fiona",
            "last_name": "Smith",
            "phone_number": "987-3595-89",
            "mental_health_referral": false,
            "date_last_mental_health_referal": "02/09/2018T00:00:00.0000Z",
            "legal_councel_referal": true,
            "CHW_id": 6866318
        },
        {
            "first_name": "Richard",
            "last_name": "Stewart",
            "phone_number": "281-0394-41",
            "mental_health_referral": true,
            "date_last_mental_health_referal": "03/23/2018T00:00:00.0000Z",
            "legal_councel_referal": false,
            "CHW_id": 9241074
        },
        {
            "first_name": "Andrew",
            "last_name": "Stevens",
            "phone_number": "068-8173-37",
            "mental_health_referral": true,
            "date_last_mental_health_referal": "03/30/2018T00:00:00.0000Z",
            "legal_councel_referal": true,
            "CHW_id": 9241074
        }
}

Now my goal is to generate only Fiona's information, which is the first data. My outline for the URL is:

GET https://herokuapp.com/api/v1/data/{{first_name}}/{{last_name}}/{{phone_number}}

I have tried something like:

https://herokuapp.com/api/v1/data?first_name=Fiona&last_name=Smith&phone_number=987-3595-89

But I am not getting the result I want and when I run the get request on Postman, I still get all the results of the API. What am I missing?

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

0

I think you should pass the parameters in API call itself just like

 axios.get(apiURL, { params: { first_name: 'Fiona',last_name : 'Smith',phone_number: 987-3595-89 } }
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!