Module:RecursiveSelectiveList: Difference between revisions
EnWikiAdmin (talk | contribs) No edit summary |
EnWikiAdmin (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
local p = {} | |||
local mw = require('mw') | |||
function p.callAPI(params) | function p.callAPI(params) | ||
local success, response = pcall(function() | local success, response = pcall(function() |
Revision as of 07:46, 22 December 2024
Documentation for this module may be created at Module:RecursiveSelectiveList/doc
local p = {}
local mw = require('mw')
function p.callAPI(params)
local success, response = pcall(function()
-- Call the MediaWiki API and return the raw response
return mw.site.api(params)
end)
if success then
return true, response
else
return false, "Error: " .. tostring(response)
end
end
function p.main(frame)
local params = {
action = "query",
list = "categorymembers",
cmtitle = "Category:Books",
cmlimit = "max",
format = "json"
}
local success, response = p.callAPI(params)
if success then
return response -- Return raw JSON response for debugging
else
return response -- Return error message
end
end
return p