Search code examples
reactjscloudinary

Cloudinary openUploadWidget throw error in my react app


I seem not to be doing something right, but I don't know what. I need to open cloudinary upload widget in my web app and it keeps throwing this error; TypeError: __WEBPACK_IMPORTED_MODULE_6_cloudinary___default.a.openUploadWidget is not a function.

I am using react and this is how I am using it...

    load = (e) => {
    e.preventDefault();
    cloudinary.openUploadWidget({ cloud_name: 'classvideo', upload_preset: 'classVideo' },
      function (error, result) { console.log(result) });
  }

This is how I tried rendering it on the click of a button inside my render method...

   <div>
      <button onClick={this.load}>upload Image</button>
   </div>

and this is the script tag in my html

  <script src="//widget.cloudinary.com/global/all.js" type="text/javascript" />
  <script src='//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script>

Is there something I'm doing the wrong way? what does webpack have to do with this? please help


Solution

  • Try adding window.cloudinary.openUploadWidget({..