User:Gauransh Dingwani/common.js

mw.loader.using( 'mw.Api' ).then( function {  // Call to the function that uses mw.Api  var api = new mw.Api; api.get( { action: 'query', prop: 'pageviews', titles: [mw.config.get('wgPageName'),] } ).done( function ( data ) { const object = data["query"].pages[mw.config.get('wgArticleId')].pageviews; var sum = 0; for (const property in object) { sum+=object[property]; }   // data["query"].pages[mw.config.get('wgArticleId')].pageviews.map((date) => console.log(date[1])); console.log(sum + " views in last 2 months"); } ); } );