On Wed, Mar 11, 2015 at 5:09 PM, Jason Ji <jason.y.ji@gmail.com> wrote:
I was trying to use the mw.Api module to do some API calls, following the general example of the documentation:

var api = new mw.Api();
api.get( {
action: 'query',
meta: 'userinfo'
 } ).done ( function ( data ) {
console.log( data );
 } );

However, I was getting an error in the JS console:

TypeError: undefined is not a constructor (evaluating 'new mw.Api()')

You probably forgot to load mediawiki.api, either by dependencies in $wgResourceModules if you're writing an extension or using mw.loader.using( 'mediawiki.api', function () { ... } );


--
Brad Jorsch (Anomie)
Software Engineer
Wikimedia Foundation