我正在将 api 数据提取到 html 表中
但收到错误消息
GET http://192.168.10.10:8000/api/ipc/all_iteml?_=1686713939003 401 (Unauthorized)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link
rel="stylesheet"
href="https://cdn.datatables.net/1.13.4/css/jquery.dataTables.css"
/>
<title>Static Template</title>
</head>
<body>
<div id="app"></div>
<table id="example"></table>
</body>
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"
></script>
<script src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.js"></script>
<script>
$(document).ready(function () {
$("#example").DataTable({
ajax: {
url: "http://192.168.10.10:8000/api/ipc/all_item",
dataSrc: ""
},
columns: [
{ data: "device_id", title: "USER ID" },
{ data: "name", title: "ID" },
{ data: "group", title: "TITLE" },
{ data: "ip", title: "TITLE" },
{ data: "port", title: "TITLE" },
{ data: "ipc_enable", title: "TITLE" },
{ data: "ftp_enable", title: "TITLE" },
{ data: "id", title: "TITLE" },
{ data: "created_at", title: "TITLE" },
{ data: "updated_at", title: "BODY" }
]
});
});
</script>
<script src="script.js"></script>
</html>
所以,我该如何解决它! 我需要建议我可以查找的关键词或很酷的解决方案
我刚刚修复了它,需要在另一端登录,获取令牌来授权服务器提取api的数据,所以这不是我的代码问题