A NUI callback never fires
A button in a script's menu does nothing when clicked, and usually nothing appears in the console either.
Do this first
Report it to the seller. There is nothing in your setup that causes this.
What it means
The browser side posted to the client and nothing happened. There is usually no error at all on either side, which is what makes it frustrating: the button simply does nothing.
What causes it
Ordered by how often it is the answer.
- 1
The URL does not match the resource name
fetch('https://my-script/buy')has to use the EXACT resource name. A hyphen against an underscore fails silently. - 2
The callback name does not match
RegisterNUICallback('buy', ...)answers.../buy, not.../Buy. - 3
cb is never called
The Lua side must call
cb(...). Without it the browser's promise never resolves, so the UI hangs even though the handler ran. - 4
The fetch has no POST body
FiveM's NUI expects a POST. A GET, or a POST with no body, may not route.
- 5
The UI is not focused
Callbacks work without focus, but the CLICK that should trigger one does not reach the page.
SetNUIFocus(true, true)is what lets the cursor interact.
How to tell which one is yours
Open the NUI dev tools and watch the network tab: is the request going out at all? If not, it is the page or the focus. If it goes out and hangs, the handler is not calling cb. If it 404s, the name is wrong.
Where to look
The fetch URL in the page, and the RegisterNUICallback name in the client script. They must match exactly.
How to fix it
-- client
RegisterNUICallback('buy', function(data, cb)
-- do the thing
cb({ ok = true }) -- ALWAYS answer, even on failure
end)
// page
await fetch(`https://${GetParentResourceName()}/buy`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ item: 'water' }),
})Still stuck on your own code?
This page is what this error usually means. Paste your console into Server Fixer and it will rank everything in it and tell you what to do first, and if you would rather not touch it, ORBIE can repair the script and hand the resource back ready to drop in.
bug_reportOpen Server Fixer