NUI: fetch / RegisterNUICallback not responding
If your NUI interface doesn't talk to Lua, it's almost always the resource name in the fetch URL. Solution and the correct pattern.
The problem
Your NUI (HTML/JS) does a fetch to a Lua callback but it never arrives, or returns 404, and the interface doesn't react.
The cause
The fetch URL uses an incorrect resource name. It must be exactly the resource name, which in JS is obtained with `GetParentResourceName()`.
The solution
Use the real resource name in the fetch and register the callback in Lua:
js
// NUI (JavaScript)
fetch(`https://${GetParentResourceName()}/miCallback`, {
method: 'POST',
headers: { 'Content-Type': 'application/json; charset=UTF-8' },
body: JSON.stringify({ accion: 'comprar', id: 3 }),
}).then(r => r.json()).then(data => console.log(data));Step by step
- 1.In JS use `GetParentResourceName()` (don't hard-code the name).
- 2.In Lua register the callback: `RegisterNUICallback('miCallback', function(data, cb) ... cb('ok') end)`.
- 3.ALWAYS validate on the server whatever comes from the NUI; the client only requests.
Related guides
Last updated: 2026-06-15. Crxative-M is not affiliated with Cfx.re or Rockstar Games.
