How to run code in JS module files?

I need help on how to utilize the Files functionality within Divhunt. Your platform doesn’t seem to have any documentation, although I found a dead link to https://docs.divhunt.com

When creating a Default JS file, my code executes automatically and console.logs are displayed in the developer tools as expected. When I create a Module file, the code does not run, and no output is shown in the console.

Here are my specific questions:

  1. How can I ensure that code within a Module file is executed? Are there special steps or a specific syntax required to run or import modules? Same question applies to plugins, functions and classes.

  2. When naming files, should I append .js extension to the filename or is it handled automatically by the platform?

  3. What is the recommended way for referencing other files within Divhunt? Do I use relative paths like ./file1.js or is there a different protocol?

Sorry, I should have elaborated on what I am trying to accomplish. In this case I am trying to pull records in from my Supabase backend, and the only way I’ve managed to get this working is by using the Custom Code feature (Head Start):

<script src="https://unpkg.com/@supabase/supabase-js@2"></script>
<script>

  // Use window.supabase to access the global supabase object from the CDN
  const supabaseClient = window.supabase.createClient('https://PUBLIC.supabase.co', 'KEY_HERE');

  async function fetchProducts() {
    const { data: supadata, error } = await supabaseClient
      .from('products')
      .select();

    if (error) console.error(error);
    console.log(supadata);
  }

  fetchProducts();
  console.log("Fetch complete");
</script>

It seems to me there should be a better way of doing this using the Files feature though, right? Just slapping everything in the <head> doesn’t seem ideal.

Hey @dejan I know you’re working on Workflow tutorials, but I’m wondering if you could pop in and answer this one (in addition to the ones above :slight_smile: ).

If I want to access data from a variable in my Javascript code shown above in a Workflow, how would I do that? For example, I want to use the supadata array of objects.

@fatherofinvention

Please allow me a bit more time and I’ll write proper explanation here, and yes it’s way better if you do it with Files feature and you can incorporate all those data natively into variables or similar.

I’ll write more detailed tutorial soon.