Module:Apitest: Difference between revisions
Jump to navigation
Jump to search
(fixed typo) |
No edit summary |
||
| Line 15: | Line 15: | ||
else | else | ||
return 'Request Failed API Down' | return 'Request Failed either the API is Down or the site ran into a unknown error please try again later' | ||
end | end | ||
end | end | ||
return p | return p | ||
Revision as of 16:43, 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 either the API is Down or the site ran into a unknown error please try again later'
end
end
return p