question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with accessing itemsjs in VanillaJS

See original GitHub issue

After integration nwb and after loading itemsjs.js script I’ve encountered a obstacle with accessing itemsjs global variable for initializing search in vanillajs

This might be helpful for reproducing:

<html>
   <head>
      <!--the old version built with browserify. it's returning object correctly -->
      <!--<script src="https://unpkg.com/itemsjs@1.0.37/dist/itemsjs.min.js"></script>-->
      <!--the new version with nwp building. it's throwing an error: TypeError: itemsjs is not a function  -->
      <script src="https://cdn.rawgit.com/itemsapi/itemsjs/master/dist/itemsjs.min.js"></script>
   </head>
   <body>
      <script>
        // it should print an object like below:
        // {search: ƒ, aggregation: ƒ, reindex: ƒ}
        console.log(itemsjs());
      </script>
   </body>
</html>

@saminzadeh any idea how it could be solved ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
saminzadehcommented, Aug 29, 2018

Sounds good, I can look into it further and will do on my on branch for now

0reactions
cigolplcommented, Aug 29, 2018

On my computer it is undefined. Seems https://cdn.rawgit.com is unreliable and showing different results based on continent, browser, etc. I guess we should not trust it as an very up-to-date cdn.

I’ve reverted master branch to the old version and created development with nwb and new plugins. Not sure if that was a good decision… Also although I’ve reverted master https://cdn.rawgit.com is not updated… The plus of development we don’t need to rush with changes

We should find a way for ensuring that wanna be master version is compatible with Vanilla Js, React Js, Node.js, etc in programmatic manner

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why I can't re-fetch my website's data using vanilla JavaScript?
The error says it all the object that is supposed to contains the image (according to your code) does not exists :
Read more >
Handling common JavaScript problems - MDN Web Docs
Incorrectly using functions inside loops that iterate with a global variable (more generally "getting the scope wrong"). For example, in bad-for ...
Read more >
The 10 Most Common JavaScript Issues Developers Face
If you need help figuring out why your JavaScript isn't working, consult this list of the 10 most common JavaScript issues from a...
Read more >
When to use Vanilla JavaScript vs jQuery ? - GeeksforGeeks
jQuery simplifies a lot of things. It's easier to implement some things using jQuery than vanilla JS. Have a look at this example....
Read more >
The problem with vanilla JS is not APIs, API is the easy thing ...
The problem is building proper architecture, so code won't quickly turn into spaghetti. With frameworks like Angular or React, it's much easier, as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found