PricingBlog

Facing isssue while loading script, in package

  • bhavikchavda-1267369607543394304

    Bhavik (Impler.io)

    1 year ago

    I'm building a CSV Excel Importer Plugin in Toddle, where at first, I need to load one script that initializes the importer. The script is meant to be loaded as follows,
    <script type="text/javascript" src="https://embed.impler.io/embed.umd.min.js" async></script>

    So Added this code in the plugin Init_Impler event,
    /**
    * @param {Args} args
    * @param {Ctx} ctx
    */
    async function Init_Impler (args, ctx) {
    const response = await import('https://embed.impler.io/embed.umd.min.js');
    console.log(response);
    if(window.impler) {
    const importerId = "1";
    window.impler.init(importerId);
    window.impler.on('message', (data) => {
    console.log(data);
    }, importerId);
    }
    }

    I called this method on page load, at first the CORS error was throwing which I resolved using the Chrome extension, but now some page-content error is throwing. The embed script is loading on the HTML page properly. Any Idea on how to fix this issue?
    1267369607732400129-image.png
  • patrickmast-1267388592963981395

    Patrick Mast

    1 year ago

    A CSV Excel Importer Plugin! Wow, that's interesting! 😎
    😊1
  • jacobkofoed-1267390546985484360

    Jacob Kofoed

    1 year ago

    Looks like their server is not reporting the file types correctly, so is not really built for es6 imports. There are a few options:

    - You could look at jsdelivr.com for the file as they support exporting modules as +esm
    - If you have an "excel" component, you could just insert the script tag in there by pasting: <script type="text/javascript" src="https://embed.impler.io/embed.umd.min.js" async></script>
  • bhavikchavda-1267390930923819008

    Bhavik (Impler.io)

    1 year ago

    Thanks, Jacob & Patrick. I figured it out by adding the following things to Cloudflare,
    1267390930713968641-image.png
    🙌2