Search code examples
javascriptapireddit

How to use snoowrap with javascript?


I have been trying to use snoop wrap with javascript to be able to call the reddit api, and I continously get an error here:

const snoowrap = require('snoowrap');

The error says:

Uncaught ReferenceError: require is not defined

I have found multiple different answers where they use browserify, but I have tried that too, to no avail. Can someone please give me a straight answer about what I have to do to solve this error?


Solution

  • I found the solution, it was just a problem on my part because I included my javascript files like so when using broser:

    <script src="originalfile.js"></script>
    <script src="bundle.js"></script>
    

    When I should have done it like this:

    <script src="bundle.js"></script>