401(未经授权)呼叫本地服务器

问题描述 投票:0回答:1

我正在将 api 数据提取到 html 表中

但收到错误消息

 GET http://192.168.10.10:8000/api/ipc/all_iteml?_=1686713939003 401 (Unauthorized)

the error pic screenshot

  • 代码如下
<!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>

所以,我该如何解决它! 我需要建议我可以查找的关键词或很酷的解决方案

jquery get token
1个回答
-1
投票

我刚刚修复了它,需要在另一端登录,获取令牌来授权服务器提取api的数据,所以这不是我的代码问题

© www.soinside.com 2019 - 2024. All rights reserved.