Accessing Shared Assets and Resources via SSA

How do you access shared assets and resources in a SSA (specifically javascript files)? I understand that, for an element, you can put script tags in an HTML header with the source equal to the file URL. Of course, there is no HTML header in the backend, so I was wondering how you can access these files.

Using the “require” feature to install NPM packages :blush:

1 Like

Hey Vini,

This was a javascript file I wrote myself - do I have to publish it as a NPM package? I was thinking that, by uploading it in the shared assets and resources section, there would be an easier way to retrieve it.

Thanks!

If it’s your own code, just include it in the body of the function is one way of handling it. (If you’re using a package that’s on NPM, just do as @vini_brito suggests.)

1 Like

That’s what I’ll probably end up doing.

It is my own code - I was trying to do it via Shared Assets because I have both a client-side element and an SSA that share several functions, so I thought it would be easier to update / manage that code from a single source.

Although, you could just use fetch in your SSA, if desired. (You might need to require node-fetch.)