I am making a little app that allows me to POST new reviews to an Reviews-API.
Definitions:
Reviews are simple JSON objects storing a few keys, some strings some integers.
Reviews-API can GET all the reviews for a given productId. It can also POST a new review (content comes from JSON body, eg. productId). Note: There are no validations on the POST preventing to create duplicate reviews.
How it works:
Table reading data from Google sheets. In this sheet I store all the objects I want to POST (1 per row). Each row can be selected.
JSONexplorer is displaying the GET result from the productId of the selected review.
Button to POST the selected review.
Problem:
I would like to set a condition on the button, so that it checks for existing duplicates inside the JSONexplorer response before sending the POST call. A duplicate is any review object that has the same value for a subset of its keys. If a duplicate is found, the POST call is not sent.
This is checking if there are any objects in the table that are exactly the same as the row you have selected in your table, and if so, the button is disabled.
If instead you just need to check a certain property you could do something like this:
Thanks for jumping in, that looks like the perfect solution indeed!
However I'm struggling to make it work. I'm getting the error query1.data.filter is not a function
@mark Thanks for that. Now the function is not returning errors so there is definitely progress! However the button still doesn't get disabled when it should. See example below:
Hmm, judging from this, it actually looks like your data property is already an array, so you should not need to use formatDataAsArray(). I think it is now just masking some other error, but strangely I don't see anything wrong. I also quickly built up my own example, also using a google sheets query as the source, and was able to get it working.
It may be easiest if you write in via chat support, so that we can potentially connect to your app to troubleshoot directly.