我试图在Vue3端的FiveM NUI中使用javascript发出一个正常的get请求。在chrome中,一切都很好,但是如果我在FiveM中打开页面,就不会加载任何内容。
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();
});发布于 2022-06-17 16:23:47
默认情况下,Fivem没有fetch函数,所以您必须将其安装到槽(Node.js)。
使用npm i node-fetch@2
const fetch = require("node-fetch");我们使用v2,因为最新的fetch是v3,它使用无法使用require的ES模块。
https://stackoverflow.com/questions/71528279
复制相似问题