0

I am trying to load and use Cloudinary's product gallery widget which is only available via a CDN (couldnt' find it as an npm module). The problem is that I get the following error in VSCODE for the cloudinary instance:

'cloudinary' is not defined.

What is the correct way to use this Cloudinary script in NuxtJs2?

Sandbox link: https://codesandbox.io/s/throbbing-tree-47pr0?file=/components/PostImage.vue

I tried to set it up like so in a component named PostImage.vue

<template>
  <div class="container">
    <div id="myGallery" ref="widget"></div>
  </div>
</template>

<script>
import "bootstrap/dist/css/bootstrap.min.css";
export default {
  head() {
    return {
      title: 'test',

      script: [
        {
          src: "https://product-gallery.cloudinary.com/all.js", //<--- load the cdn here??
          async: true,
          defer: true,
        },
      ],
    };
  },
  mounted() {
    this.loadWidget();
  },
  methods: {
    loadWidget() {
      const myGallery = cloudinary.galleryWidget({
        container: this.$refs.widget,
        cloudName: "demo",
        mediaAssets: [{ tag: "clock" }], // by default mediaType: "image"
      });
      myGallery.render();
    },
  },
};
</script>
kissu
  • 40,416
  • 14
  • 65
  • 133
redshift
  • 4,815
  • 13
  • 75
  • 138
  • 1
    Let me try the "Deltner" way, and if issues, I'll report back! Thank you. – redshift Dec 14 '21 at 14:20
  • Just need a bit more help: https://stackoverflow.com/questions/70351691/how-to-use-cloudinarys-product-widget-as-a-plugin-for-nuxtjs2-apps – redshift Dec 14 '21 at 15:48

0 Answers0