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

242
Views
What is the best practice to create a GET request with many parameters

Our backend developer implemented an endpoint that allows GET method to get a list of Assets of the database. To filter the Assets that I want in the response, I need to pass some parameters in the URL.

First I implemented the following function to mount the GET request with all available parameters:

fetchAssetList(data) {
    let request_url = 'asset-mgt/assets?'
    if (data.name !== '' && data.name !== null){
      request_url = request_url + "Name=" + data.name + "&"
    }
    if (data.assetCode !== '' && data.assetCode !== null){
      request_url = request_url + "AssetCode=" + data.assetCode + "&"
    }
    if (data.parentAssetName !== '' && data.parentAssetName !== null){
      request_url = request_url + "ParentAssetName=" + data.parentAssetName + "&"
    }
    if (data.type !== -1 && data.type !== null && data.type !== undefined){
      request_url = request_url + "Type=" + data.type + "&"
    }
    if (data.parentAssetId !== -1 && data.parentAssetId !== null && data.parentAssetId !== undefined){
      request_url = request_url + "ParentAssetId=" + data.parentAssetId + "&"
    }
    
    return axiosPrivate.get(request_url);
  },

I am not really happy with the current solution we implemented. The GET request with such many query parameters does not feel right.

Do you think it would be better to have one GET Method which always returns all assets (.../assets), other GET method which takes the id of the asset (.../assets/{id}) and one POST method, which takes a payload to filter (.../assets/filter). What is the best practice?

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