Need help on "Cannot read property 'xxx' of undefined. " Error in REST API call

Hi All,

I am getting the below exception while triggering the REST API when the button is clicked in the table.

Cannot read property 'S3Data' of undefined.

Here is what I am doing in the app.

  1. Call the REST API#1 and populate the data in the table.
  2. Added Action Button with Label as "Download".
  3. When the Download button is clicked then it needs to get the column of the selected row as input and call the REST API#2.
  4. REST API#2 gets the data specific to the table row and using utils. downloads to download the file.

Here is the query I am using for downloading the data

//REST API#2 call
getArchiveData.trigger();
//Download the data from REST API#2
utils.downloadFile(getArchiveData.data.SelfServeInvoiceAPIResponse.S3Data.edi_data,getArchiveData.data.SelfServeInvoiceAPIResponse.S3Data.s3_file_name,'')

When I click first, looks like it's not returning any data in S3Data, and want to check how to disable this error message.

This error goes off when the query runs and I need to click 2 times to download the data.

I have also noticed, it always downloads the previous row data instead of getting the current row. How can I get the data of the current row?

Here is the parameter that I am passing from table1 to get the data from REST API#2.

"downloadS3Data":[
{
"invoiceNumber": {{table1.selectedRow.data.invoice_number}},
"ExecId":{{table1.selectedRow.data.exec_id}}
}
],


Hi @saravanakumar84 :wave: thanks for reaching out with this question!

Based on the screenshot you provided, it appears that the call to getArchiveData.trigger() is not being awaited – as a result, the .data property will just return the payload from the last time it was run. The reported behavior should be resolved by awaiting the getArchiveData.trigger() call; something similar to:


I hope that helps out – let us know if you have any other questions though!