How to save e.g. an ID from the Response of a Xano API POST request?

I wonder if it is possible in React Studio to save e.g. an ID to a DataSlot after a successful Xano API POST request?

This is very important if one has a header / detail table structure.

Imagine two tables where one is the Project Header table like this:
id // unique project id
name // project name

Project detail:
id // unique project detail id
project_id // foreign key to project header id

If the project header record gets created (using a POST request) the project id auto number that Xano provides for this record needs to be saved in a DataSlot and if later a detail record gets created it needs to be provided as input for the API request so that the project_id gets saved in the detail record and points to the header record.

I wonder how this can be achieved?

Hi and thanks for the really good feature request.

We’ll check this out and try to figure out how to tweak the plugin and get the ID back to Data slot after the successful Post (Create) interaction.

Hi Antti, thanks for checking this out …
I just wanted to add that it does not have to be limited to the ID.
Xano can deliver different responses back like e.g. a JSON object …
If this could be saved to a DataSlot that would open up a lot of possibilities!

I hear you. The problem with storing JSON object into Sata sheet is that most users don’t know how to use it. It would always require some sort of script to pull the field value out of the object. Maybe we should have a new data block called Data row or JSON object which would then act as global variable as Data slot but could contain multiple “columns” like Data sheet?

Yes, a DataSlot that can take a JSON object and could be easily addressed with punctuation would be best. However, it is an advanced feature and if this is a lot of work for you then I would just save the response data to a DataSlot that can be chosen. The user could fix the problem at the Xano end and send just the ID as response if they don’t know how to write a script in React Studio to extract the data they need.

We’d like to make this as versatile and easy to use as possible and I’m confident we’ll figure this out somehow.

Btw. you can already test and edit the Xano plugin yourself. I think you could try to simply edit the plugin and hard code the JSON object saving into data slot in the plugin code. Then just save the plugin and click reload plugins from Plugins menu or restart the studio.

Thanks Antti, I am going to try this out …

If anybody else would like to do this … I added the selected lines of code and this works nicely. The created ID is saved in the DataSlot “ds_saved_id” after a successful post request.

1 Like

Great that you got it working! We’ll definitely come up with a solution for this but in the meanwhile you can use your “customised Xano plugin”.