I am trying to use RequireJS to use the require() function in the browser. For context, I am trying to work with the Node wrapper for the Lob API: https://github.com/hisankaran/lob-node.
Here's the relevant code:
define (function (require) {
var LOB = require('lob');
LOB = new LOB(API_KEY);
})
// var LOB = new (require('lob')) (API_KEY);
console.log('Success?')
It runs successfully, but when I try to actually call anything, for example LOB.bankaccounts.create, it says LOB is not defined.
The Lob docs suggested that I do simply this:
var LOB = new (require('lob')) (LOB_API_KEY);
but I kept getting that the module had not yet been loaded for context error described here (http://requirejs.org/docs/errors.html#notloaded), so I tried the above syntax from the RequireJS website.
I'm super new to RequireJS (and coding in general), so I may just be doing something silly.