You do not have permission to edit this page, for the following reason:
You can view and copy the source of this page.
local common = {}
--- Checks if Api Request was successful and if the Response is valid
--- @param response table
--- @param errorOnData boolean
--- @param errorOnData boolean
--- @return boolean
function common.checkResponseStructure( response, errorOnStatus, errorOnData )
if response[ 'status_code' ] ~= nil and response[ 'status_code' ] ~= 200 then
if errorOnStatus == nil or errorOnStatus == true then
error( 'API request returns the error code ' .. response[ 'status_code' ] .. '(' .. response[ 'message' ] .. ')', 0 )
end
return false
end
if response[ 'data' ] == nil then
if errorOnData == nil or errorOnData == true then
error( 'API data does not contain a "data" field', 0 )
end
return false
end
return true
000
1:0
Templates used on this page:
- Template:Documentation (view source) (protected)
- Module:Array (view source)
- Module:Common (view source)
- Module:Common/Api/doc (view source)
- Module:Common/SMW (view source)
- Module:Common/testcases (view source)
- Module:DependencyList (view source)
- Module:DependencyList/i18n.json (view source)
- Module:Documentation (view source)
- Module:Documentation/i18n.json (view source)
- Module:Documentation/styles.css (view source)
- Module:Faction (view source)
- Module:Format link (view source)
- Module:Hatnote (view source)
- Module:Hatnote/styles.css (view source)
- Module:Hatnote list (view source)
- Module:I18n (view source)
- Module:I18n/category/en.json (view source)
- Module:ItemPorts/Vehicle (view source)
- Module:Mbox (view source)
- Module:Mbox/styles.css (view source)
- Module:Module toc (view source)
- Module:Paramtest (view source)
- Module:ScribuntoUnit (view source)
- Module:ScribuntoUnit/config (view source)
- Module:Translate (view source)
- Module:User error (view source)
- Module:Vehicle (view source)
- Module:Vehicle/sandbox (view source)
- Module:Yesno (view source)
Return to Module:Common/Api.