I try to make a normal get-request in javascript in a Vue3 side in FiveM NUI. In chrome everything works just fine but if I open the Page in FiveM nothing loads.
fetch("http://xxx.xxx.xxx.xxx:xxxx/postinserat", {
method: "POST",
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(data)
}).then(res => {
console.log("Request complete! response:", res);
this.titel = "";
this.beschreibung = "";
this.telefonnummer = "";
this.preis = "";
this.currentPage = 0;
this.getInserate();
});
Fivem doesn't have fetch function by default so you have to install it trough (Node.js).
npm i node-fetch@2const fetch = require("node-fetch");We use v2 because the latest fetch is v3 which uses ES modules that won't work with require.