So it's strange, about ten or fifteen minutes after I posted that, the
error went away while I was fiddling with something or other. One of those
really strange (and terrible) magically disappearing bugs... so the
following is no longer urgent, but more for my own edification.
You're right that I never load mediawiki.api. (However, I'm still not
loading it and the problem has resolved itself.) But why would I need to
load mediawiki.api, and not other mediawiki JS modules? I've been able to
use other mw modules in JavaScript without any issues (example: mw.user for
getting tokens, or mw.config to get various $wg variables).
--
Jason Ji
jason.y.ji(a)gmail.com
On Wed, Mar 11, 2015 at 7:22 PM, Brad Jorsch (Anomie) <bjorsch(a)wikimedia.org
wrote:
> On Wed, Mar 11, 2015 at 5:09 PM, Jason Ji <jason.y.ji(a)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
>
> _______________________________________________
> Mediawiki-api mailing list
> Mediawiki-api(a)lists.wikimedia.org
>
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
>
>