Search code examples
mediawikicategoriesmediawiki-api

MediaWiki API isCategory


I need to know the category of the page. I've found mw.Api.plugin.category , but couldn't make it work. I'm trying to pass the category name as a parameter but im getting the error message that isCategory is not a function.

I tried reading "api" below, to know what are it's methods,etc, and i don't see isCategory on it.

var api = new mw.Api();

I already used mw.user.getName() from the documentation and it's working.

Can anyone tell me how to use the code, please? Any exmaples and links would be helpful.


Solution

  • If you're looking for the category of the current page, you can simply use the page-specific properties of mw.config:

    mw.config.get("wgCategories")
    

    No need for an api call!