Access data table records from JS

Hello Tadabase community!

I’m looking for a way to find some kind of object that stores records for the data tables so I can use them (iterate, etc) on my code. Is it possible to access them from js? (I know I can access loggedInUser but I’m talking more about plain records).

Thanks in advance!

Hello @jmendoza, welcome to our community! :smiley:

There are a few options you can use to access an array of records for programmatic use.

Option 1 - The Tadabase JavaScript API
The JavaScript API can be used to get an array of records that are currently being displayed on a component. For example, if I have a table component on a page with the component ID of component_3, I can add the following code to the JavaScript section of the page.

TB.render('component_3',function(data){
    console.log(data.records);
});

Option 2 - Custom Component
While I’m unsure what your use case is for this, I’m positive that you’ll be interested in our brand new Custom Component. :smile: Please feel free to check it out and contact us if you’d like to try it out.

Option 3 - Our REST API

More info can be found here -> https://docs.tadabase.io/categories/manual/article/rest-api

Hello @Chem and @Moe

I know it says: “You can use our extensive REST API to access and update your app data from other platforms.” (https://docs.tadabase.io/categories/manual/article/rest-api) but I have a question:

Is the ‘Option 3 - Our REST API’ at least 99% secure to use inside js tab (authenticate there, etc)?

Screenshot_2021-07-09_09-20-25

(just want to confirm there aren’t risks of leaking my API keys as I deal with very sensitive data). When I tried printing something to console with console.log I was able to see ALL the code written there from the dev tools on chrome, so my guess it probably isn’t so secure to do that. What do you think is the way to make it secure?

Use-case: I’d like to automate stuff that uses both Logged-in values and other tables/records, so I was trying to build some scripts that do the job. Also, dynamically update/read/delete data from the records based on interactions on the site (which I can do using DOM manipulation).

Thanks in advance!

@jmendoza This is a great question.

Please never save any API credentials in the Javascript of the page or app. This is 100% not secure and your credentials will be exposed.

You can likely achieve similar results by using hosted scripts. For example, using a Google script as a web app, or more complex, a lambda function.