Hi All - Creating my first plugin and can’t seem to link the output of my code with what Bubble needs in order to pass it back into my app. Here are the details:
Here are the keys in the required format to define the JSON object my function should return, per Bubble:
Here is my ‘Action Code’ - how can I improve it so that the results can be passed back to my app?
Is the code executing okay outside of the returned values? (ie are there values for height and width generating?)
If the only issue is the return and height and width are already entered into your returned values in the property editor you can try reorganizing the code so that the necessary values are returned a bit more directly, that might help, for example
I think you would have to rearrange things quite a bit in the
you can wrap things into a try-catch here what’s the get image dimensions (url might look like on the bottom and then you’d also need it to be an async function (properties, context) up top…might be something to try
try {
const dimensions = await getImageDimensions(imageURL);
console.log(dimensions); // Optionally log the dimensions
return {
height: dimensions.height
width: dimensions.width
};
} catch (error) {
console.error(error.message); // Log the error message
throw error; // Rethrow the error if you want the caller to handle it
}
}
I assume that you are just copy-pasting code without understanding what it is because Image is a browser api therefore your code will not work in a server action as is.
This should be a client side action of a element and should use element’s state and events to overcome bubble’s limitation of client side actions not returning data. A search in the forum will bring up many topics about the necessary workaround.
@lola thank you for your reply(ies)! I sincerely appreciate it/them. With @dorilama’s response though, I fear my issue might be more fundamental after all.
@dorilama thanks for the feedback! Good news: there actually already exists a client-side plugin for getting the image data I need. I was hoping to avoid the workaround (as it’s a bit clunky) but I suppose such is life for now and feel a bit better about implementing it knowing that what I wanted to do on the backend can’t actually be done at the moment.
That said, if anyone reading this post believes that they do have a way to enable this to work as a server side action (which includes a browser api), I am all ears and would very much appreciate any help you can give. Thank you!
no problem, yeah I didn’t look too deeply as to what API you were using. Anything that needs to run in the browser won’t be able to run on the server so you’ll need a client-side action or element!