Using table row values for new API request parameter

Hi there!
So, I have a table generated from an API request which contains a list of project.
Each project is identified by an “uid” value which I’d like to use as a parameter for another API request in the same table.
Ideally, I’d add a new column in the same table and display the second request output in the Computed Value for the new column.
My issue is: how can I do this?
If I use something like {{project_table.selectedRow.uid}} in my new API request, it works, but I’m getting only the uid of the first relected row instead of the uid of each row.

Thanks,
Enrico

@enricogiaistar In the Computed column for the second api request, you can use {{currentRow.uid}} as param. This should give the uid of each row. Please let me know if I understood your question correctly.

Hi @dancia,
I already have the uid for each row, and I want to use each of values as a parameter in the new API request.

This is my table:
image

This is the “list_analyses_by_project” request I’m currently using for the NewColumn:
GET: https://cloud.xxx.com/web/api2/v3/projects/{{projects_table.selectedRow.uid}}/analyses?token={{appsmith.store.token}}

And this is the Computed column value for NewColumn:
{{list_analyses_by_project.data}}

As you can see, it works, but the only UID passed is the first one in the list (the selectedRow).
I tried using currentRow in the api request, but it doesn’t work :frowning:

Ah, I get it now. We may have to use JSObjects to achieve this. Give me some time. Let me get back to you with an example app if possible.

1 Like

@enricogiaistar It was a bit more complicated than I thought it would be and needed help to get the JS function working :sweat_smile:

But here’s the app that you can fork. Page Name - Merging data from two APIs
https://app.appsmith.com/applications/61fae6cc2cd3d95ca414a84d/pages/62712ae18a368d6f1ef5ced8

I have added comments above the functions in JS Objects. In the table widget second_res is the column which pulls the data based on the column value from the first API.

Hope this helps :slight_smile:

1 Like

@dancia, you’re great! Thank you so much, you really saved me :slight_smile:

1 Like

And I have @pranav and @vihar to thank for helping out as well :slight_smile:

2 Likes

@enricogiaistar onPageLoad, you can create a JS Function that loops over all the rows in the first API and makes a request for each of the rows. You can store the response of each request using storeValue(uid, response) and then have a function that iterates over the first API response and merges it with the values in the store