Hey all,
could not find this as a topic so thought I share. Just made a massive breakthrough setting up a Rest API as a datasource.
During a Web Dev class last year, I set up an API for a movie Database.
This had a few objects in it and if you want all parts of an objects to be split and used in Softr you need to use the Transformer feature during the Database setup.
Sharing here my JSON for the full info I had for a movie. for the highlighted objects, Softr keeps this info as a ‘group’ so if you wanted to e.g. show a genre type - it would put out: {“Type”: “Thriller”,“Description”: “Gives you the chills.”}
as text.
==============================
{
“Genre”: {
*** “Type”: “Thriller”,***
*** “Description”: “Gives you the chills.”***
*** },***
***"Director": {***
*** “Name”: “Darren Aronofsky”,***
*** “Birthyear”: “1969”***
*** },***
"_id": "66a374b384a37c5b1b60c5c8",
"Description": "A ballerina's role in a New York City ballet creates a consuming obsession that leads to her psychological unraveling",
"Title": "Black Swan",
"Actors": [
"Natalie Portman",
"Mila Kunis"
],
"ImageURL": "https://cdn11.bigcommerce.com/s-yzgoj/images/stencil/1280x1280/products/2893777/5958907/MOVCB83563__34494.1679602412.jpg?c=2",
"Featured": true
},
===============================
Giving Chat GPT a pat on the back here for spitting out this transformer code - but I had to add the parts in bold:
return response.map(movie => ({
Title: movie.Title,
Genre: movie.Genre.Type,
** GenreDescription:movie.Genre.Description,**
** Director: movie.Director.Name,**
DirectorBio:movie.Director.Bio,
DirectorBirthyear:movie.Director.Birthyear,
Actors: movie.Actors.join(', '),
Description: movie.Description,
ImageURL: movie.ImageURL,
Featured: movie.Featured
}));
===============================
Happy coding and using REST APIs