How to use tinify API in website code?

Hi, I’m trying to include a feature in my website where I get an image from a third party website, upload it to tinify, compress it, and upload it to Wix Media to use in one of my collections.

I was wondering if such a workflow is even possible in Wix Editor.
I’m trying to follow the official API here (TinyPNG – API Reference), but keep getting errors.
I’m getting the following error in my collection, which displays when hovering over a red exclamation mark on the left of the clicked item in my collection.

The code for one of your data hook functions threw an error. Check your code and try again.

Where can I check the contents of this error anyway? I tried looking at Monitoring or Logs area but found nothing about it… I was even trying to log the error content directly to some random field in my collection, but that has some limitations and is kind of a bad practice… :sweat_smile:

I have already npm installed tinify and published it, but can’t seem to be able to import it or use it correctly…

The goal is to trigger this workflow when manually making a certain change in my collection, using a data hook. Up to here I was able to do it, and I can successfully apply other changes to the same collection and even other collections, but the tinify call is what is troubling me.

Does anyone have any hints on this? Would be much appreciated!

Sorry if I’m trying something completely impossible or nonsense… Please tell me if that’s the case!

Thanks in advance for any help!

Hi, @Andre_Moreira !!

Hello. Assuming you’re able to use tinify in the backend code, any errors that occur can be checked by going to your Site Dashboard, then navigating to Developer Tools > Log Management > Wix Logs. Please use this section to review any backend errors. (It’s a good idea to keep this Wix logs screen open in a separate tab while you’re working on your site.) :innocent:

1 Like

Hi @onemoretime !

Thank you so much for the tip!
While not being the direct answer to my problem, it did lead to the solution!
I was not aware that the Wix Logs would react after making changes in the collections and checking that in real time in the Logs tab. That was certainly revolutionary for my workflow! Thank you so much!

After following the logs for some time, I was able to put tinify up and running, and I’m now able to display the compressed images in my website!

Thank you so much once again!!!

1 Like

I’m glad I could help resolve the issue. :innocent: Enjoy Wix! :smiling_face_with_sunglasses:

1 Like