我正在尝试对我的服务器执行简单的GET请求。URL是正确的,它使用python函数给出json。但是我无法在javascript中获得相同的数据。此函数有问题。
async function get_status(){
socket.send("Status!");
URL = http://127.0.0.1:8000/api/status/';
response = await fetch(URL, {
method: "GET",
headers: {
"Accept": "application/json"
}
})
socket.send(response.json());
console.log(response.json());
if (response.ok) {
current = document.getElementById("status");
current.value= response.json()["status"];
}
};
当年话下
相关分类