Module:RecursiveSelectiveList

From Ikwipedia
Revision as of 07:45, 22 December 2024 by EnWikiAdmin (talk | contribs)

Documentation for this module may be created at Module:RecursiveSelectiveList/doc

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