Category: Question and Answers
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

How to filter the specific data in an API by using list

Issue

I need help filtering and displaying a specific status field data in a list widget after making an API call using JavaScript. I have received the response data successfully in the console, but I am unable to show the filtered data in the list. I'm looking for guidance on how to use the .filter() method to filter data based on its status field. Additionally, I have a button that redirects me to a page where I need to access the ID. Can you help me send query parameters with the URL using navigateTo and access them on the next page with appsmith.URL.queryParams?

Resolution

The user was trying to filter data by a status field ("pickup" or "drop") returned from an API call and display only the "drop" status data in a list widget. To solve this, they can use the .filter() method in JavaScript to filter the data based on the status field. They can use code similar to this:

parcel_reservation_dtl.data.records.filter(record => record.reservation_status === "drop")

This will return a filtered array containing only records where the status is "drop".

If the user needs to access the ID on the next page after being redirected from a button click, they can send query parameters with the URL using navigateTo and access them on the next page with appsmith.URL.queryParams.