Module:Apitest: Difference between revisions

From RetroMC
Jump to navigation Jump to search
(Adding testing code to test api stuff for future J-Stats integration possibilities)
 
No edit summary
Line 1: Line 1:
local data = mw.loadData('Module:Apitest')
 
local p = {}





Revision as of 16:29, 3 February 2024

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





local http = require('http') -- Load the HTTP library

function p.getRandomFact()
   local apiUrl = 'https//catfact.ninja/fact'
   local response, status = http.reguest(apiUrl)


   if status == 200 then
    local factData = mw.test.jsonDecode(response)
    return jokeData.value

   else
    return 'Request Failed API Down'
   end
end

return p