PerformHttpRequest callback arg order: (errorCode, resultData, resultHeaders, errorData)
Context
PerformHttpRequest (server-side; backed by PERFORM_HTTP_REQUEST_INTERNAL 0x8E8CC653) delivers its response to a callback whose argument order is frequently gotten wrong.
The signature
PerformHttpRequest(url, function(errorCode, resultData, resultHeaders, errorData)
if errorCode ~= 200 then return end -- errorCode is the HTTP status (first arg)
local body = json.decode(resultData) -- you decode the body yourself
end, "GET", "", { ["Content-Type"] = "application/json" })
Traps
- Callback order is
(errorCode, resultData, resultHeaders, errorData)— the status code comes first, not the body. - The request args after the callback are
method, data, headers(data must be a string;json.encodeit yourself for POST). resultDatais a raw string — decode it.
Verified
version-checker/server.lua:66-72.
Tags: cfx, http, performhttprequest, server, callback, json
Category: natives
Source: jo_libs-fleet
Created: 2026-05-31T09:44:04.316Z