So i have an API that I can call that looks like https://server/user/widgets that returns a list of widgets the user has. And I have a call like https://server/widgets?query=something that returns a list of widgets based on a user search term.
Unfortunately the resulting API calls seem to create two different Widget objects with exactly the same fields. I want to be able to display them using the same reusable component - is there a way I can cast one into the other, or configure the second API call to deserialize to the exact same object?
1 Like
Yes I had this issue as well, I have to make a plugin where all the API calls were done through actions and the code would return the same datatype for both actions, it was a pain.
Possibly if you have your own backend workflow you call with the API or App Connector…
API call to backend workflow → workflow does API call to external service and returns the 1st datatype → return that to original API call as the “common” 3rd datatype
API call to backend workflow → workflow does API call to external service and returns the 2nd datatype → return that to original API call as the “common” 3rd datatype

That’s really disappointing - i was hoping the API connector would make it trivial to use bubble for the front end for an custom API app that we’re building, but not being able to reuse visual components for different API calls sinks that really quickly.
Are you able to share any sample code or screenshots of how you’ve got your plugin configured? I can’t quite wrap my head around how i’m supposed to define new Plugin Types. Also presumably this approach means I’ve got to manage making my own API calls when the page loads, rather than just depending on “Search for…”
That’s a good idea… A plugin to convert across datatypes with the same fields…
Are you saying right now your API calls are data sources not actions?
Yeah right now i’m just using a data source. Maybe invoking it as an action would make more sense, but it’s also a lot of fields to have to remap every time
Is there some path where i can serialize the object to JSON and then deserialize as the new type in a workflow?
1 Like
If the API-response for both API calls is the same, using a dynamic URL might solve your issue. In the workflow you use to retrieve the data you will be able to set the URL and params for the call.
I’d considered that. I control the API so I can have some flexibility there, but unfortunately I can’t even have the Widget object at two different places in the same API response and have it map to the same object 
A plugin can convert between API datatypes, I was messing with it and just need to get it working