Can a custom element make an http request?

Hi all. I am making a wix-fetch call that sends me back a blob (of application/pdf type). I trigger this when the user presses a button and I want to download the resulting pdf (or display it on another tab or print it directly, not sure yet).

From what I understand, I cannot get the blob out using wix-fetch: HTML5 Blob | Velo |

I’ve been reading up on custom elements and I’ve looked at this example: QR Code Generator | Velo by Wix Examples | .

What I think I can do, is add a custom element for my button, which when pressed will run code I’ve added to the custom element that will send a regular javascript XMLHttpRequest get request, get the blob out of the response, and create a URL from it to display/download/print.

Will this work? The http request I send out will have an API key that I don’t want to expose. It looks to me like I can pass this to the custom element (retrieved from the backend) without having to expose it in code anywhere.

It all looks a little complicated, so I’d love to confirm my approach is valid first. :slight_smile:


You do not have to go that hard and difficult way.
You also can do the same → by using an HTML-Component.

And there are also enough examples here in this forum for your wished functionality.

Just search for KEYS like… —> blob, base64, file-selector (file selector), buffer and you will surely find a post, which will show you what you want.

Here an example → 5secs of seach …

    After this post → the multi-upload-button was born :sweat_smile:

Thank-you Velo-Ninja. I had started with an HTML Component, but I couldn’t get it to work so I thought maybe it wasn’t possible. More likely, I was doing something wrong as I don’t quite understand this area. I will look at those posts and try again.