REST API record id requirements

I have a dataset saved in JSON format being served from https://jsonbin.io/ to Appgyver’s REST API integration. It is displaying just fine as a list but when I try to pass a field as a record ID to a page displaying a single record no data is fetched. I think it has something to do with not defining my record ID correctly. How should I format and define a Record ID? Or do you think it might be something else?

The ID format should not matter, but looking at the JSON bin docs quickly, it does not look like they offer a way to fetch a single record through an API.

What you can do is fetch the whole collection with Get data collection but then use a single record type data variable and in the Set data variable node find and set the right item with a formula like SELECT(outputs["Get data collection"].records, item.id === params.id)

1 Like

Thank you so much for your help - I partially understand what you are suggesting. I have limited (no) programming skills. Could you break it down a little for me? Would i put a JS node between the DATA node and the VARIABLES node with that code? What do I replace “Get data collection” with? Sorry but I’m throwing myself into the deep end and have big holes in my fundamentals. If this is too much of an ask let me know. Happy to give you access to my app if specifics would help an answer. Apprecaite the doors you’ve opened for me so far.

Also I’m not committed to JSONbin.io as a host. I notice a bit of support for google Firestore so perhaps that might be a better host for me if the single record thing wont be a problem there.

So point being that the data variable is simply a page variable with a schema from the connected data resource, so it can host any arbitrary data you store there. The Get data collection node makes an HTTP call to the backend to get the data, but at that point you just have the data – you need to store it in a variable to show in the app.

Thus, what you can do is add the single record type data variable and open its logic canvas. It has two nodes – one to fetch data (which can’t work since JSONbin.io has no “get single record” API route) and one to set the fetched data into the data variable.

You can modify the flow by replacing the Get data record node with the Get data collection node, then change the Value input property of the Set data variable node from the (now defunct) Get data record / Record direct flow function output binding to the formula above. Thus, the logic fetches all data, then filters the desired record out of it.

That said, since you already have all the data at hand, it makes no sense to refetch it – so if you instead stored your data into an app variable, you could run the same formula against the app variable array without having to refetch it. The only caveat is that you currently need to copy the schema over by hand.

1 Like

I understand a good 80% of these words and am confident I’ll figure out the rest when I play with this again next weekend. You, sir, are a god amongst men.

1 Like

Hi Harri - Quick question - my data collection will have 7000-10000 records - will this be too big to store the whole array locally as an app variable?

Depending on the amount of data in an individual record, that can be anywhere from a few MB to some tens of megabytes, which shouldn’t pose a problem memory usage wise. Of course, with a dataset that big, running e.g. formulas against it will be slow, so you should pick a subsection of it when actually utilizing it in the app instead of binding e.g. a repeat directly to a SELECT formula.