Firing an API request for each row in a table

Hi @nils!

If you want to trigger your GET query as a part of your script you can do so with an await statement, then you can check for duplicates in a way similar to what you did here (I'll use your query from that post as an example).

At the top part of your script you can declare another variable var reviewData = await GETdev.trigger(); and then modify the runQuery function with the following code:

function runQuery(i){

  // first part of function..

  var author = table1.data[i].author;
  var description = table1.data[i].description; 
  if(reviewData.data.filter(x => author == x.author && description == x.description).length>0){
    console.log('Skipping duplicate post', i);
  } else {
    console.log('Running query for row', i);
    POSTalldev.trigger(/*...*/);
  }
}

To avoid duplicate posts that result from multiple clicks it might be best to move this script into a separate query (or queries) and then disable the button until the query has finished!

1 Like