Problem with accessing itemsjs in VanillaJS
See original GitHub issueAfter 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:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sounds good, I can look into it further and will do on my on branch for now
On my computer it is
undefined
. Seemshttps://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 createddevelopment
withnwb
and new plugins. Not sure if that was a good decision… Also although I’ve reverted masterhttps://cdn.rawgit.com
is not updated… The plus ofdevelopment
we don’t need to rush with changesWe should find a way for ensuring that wanna be
master
version is compatible with Vanilla Js, React Js, Node.js, etc in programmatic manner