VirusTotal / vt-augment

The VT Augment widget is an official, compliant and recommended way of integrating VirusTotal data in third-party applications.
Other
35 stars 10 forks source link

Unexpected Type Error #22

Closed mefp closed 2 years ago

mefp commented 2 years ago

I'm getting a Type Error and I can't figure out why. I'm using the following code inside an onclick event, inside a component from the Material UI React lib.


  const container = document.querySelector('#vt-augment-container');

  const options = {
    background: '#fff',
    closingFromOutside: true | false,
    mode: 'drawer' | 'standalone',
  };

  const vtaugment = new VTAugment(container, options);

  vtaugment.load(vtHTMLUrl).openDrawer();

The offending line seems to be the one which instantiates the new VTAugment object. It happens both with the declared options object and with an empty object.

I have verified that the querySelector is working and also that the URL I'm passing to the load function is valid.

Here is the error output:

TypeError: e is undefined
    vb vt-augment.min.js:73
    Z vt-augment.min.js:63
    onClick Table.js:1110
    promise callback*onClick Table.js:1099
    React 14
    unstable_runWithPriority scheduler.development.js:468
    React 15
    <anonymous> app.js:223
    js app-094bb9ab3b626bb2c09c.js:2342
    __webpack_require__ app-094bb9ab3b626bb2c09c.js:80
    2 app-094bb9ab3b626bb2c09c.js:7538
    __webpack_require__ app-094bb9ab3b626bb2c09c.js:80
    checkDeferredModules app-094bb9ab3b626bb2c09c.js:46
    <anonymous> app-094bb9ab3b626bb2c09c.js:153
    <anonymous> app-094bb9ab3b626bb2c09c.js:156
mefp commented 2 years ago

Still getting errors with this issue. I'm trying to load the module via Webpack from inside React. Any help would be appreciated. Thank you in advance.

danipv commented 2 years ago

Hi mefp, Did you solve this problem? I guess the problem comes from import the library as javascript module with webpack, the library is intended to be loaded as UMD. ESM will be supported in the future.

mefp commented 2 years ago

I was unable to solve it directly. Instead, I make standard requests from within my React app and manipulate the HTML that is returned. Is there a better way to do it?

danipv commented 2 years ago

Have you tried to include the script in the main html file?

<!--- "VTAugment" will be attached to the global window object. -->
<script src="./node_modules/@virustotal/vt-augment/dist/vt-augment.min.js"></script>
mefp commented 2 years ago

I remember trying that but can't remember why it wasn't working. The ticket for integrating the VT widget was a while ago. But it's working now with my hack and I have full control over styling of every element and click events, etc.