0

我正在尝试form-urlencoded在 Axios中发帖

这是我的代码

const qs = require("qs");
const axios = require("axios");

const tmp = { id: "96e8ef9f-7f87-4fb5-a1ab-fcc247647cce", filter_type: "2" };

axios
  .post("https://www.lalal.ai/api/preview/", qs.stringify(tmp))
  .then((result) => {
    console.log(result);
  });

这是我得到的

(node:2440) UnhandledPromiseRejectionWarning: Error: Request failed with status code 403
    at createError (D:\reactjs\crud-mern\server\node_modules\axios\lib\core\createError.js:16:15)
    at settle (D:\reactjs\crud-mern\server\node_modules\axios\lib\core\settle.js:17:12)
    at IncomingMessage.handleStreamEnd (D:\reactjs\crud-mern\server\node_modules\axios\lib\adapters\http.js:244:11)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2440) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:2440) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

谁能向我解释错误是什么以及如何解决?感谢:D

4

1 回答 1

1

在错误响应中它指出Request failed with status code 403。403 通常表示“禁止”并且您无权执行该请求。我会检查以确保您拥有发出该请求所需的任何访问密钥、令牌或授权。

403 Forbidden:服务器理解请求,但拒绝执行。(来源

于 2020-12-09T19:32:49.333 回答