Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/427.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在nodejs中发布url编码的Api,但仍然出现错误_Javascript_Node.js_Reactjs_Axios_Urlencode - Fatal编程技术网

Javascript 在nodejs中发布url编码的Api,但仍然出现错误

Javascript 在nodejs中发布url编码的Api,但仍然出现错误,javascript,node.js,reactjs,axios,urlencode,Javascript,Node.js,Reactjs,Axios,Urlencode,嗨,我是javascript新手,我试着从lala.ai发布url编码的Api。一、 m按照互联网上的指示进行操作,但仍然出错。下面是我的代码和结果 //This is the instruction POST /api/preview/ Puts a file in the preview queue (the first minute of vocals). Parameters (form-urlencoded): id (str): File id obtained

嗨,我是javascript新手,我试着从lala.ai发布url编码的Api。一、 m按照互联网上的指示进行操作,但仍然出错。下面是我的代码和结果

//This is the instruction

POST /api/preview/
    Puts a file in the preview queue (the first minute of vocals).

Parameters (form-urlencoded):
    id (str): File id obtained from /upload/ method.
    filter_type (int, optional): Number of postprocess iterations with MWF.
    webpush-callback (json, optional): Client data for sending push notifications.

Returns (json):
    {
        "status": "success" | "error"
        "error": Error description if the status is "error"
    }

Examples:
    $ curl --url https://www.lalal.ai/api/preview/ --form-string "id=9a3ae258-7693-4046-87c2-ef577eb752bb" --form-string "filter_type=2"
    {"status": "success"}

    $ curl --url https://www.lalal.ai/api/preview/
    {"status": "error", "error": "No file id"}
这就是我尝试过的

const qs = require("qs");

axios
  .post(
    "https://www.lalal.ai/api/preview/",
    {
      data: qs.stringify({
        id: "4d2f9262-e578-4290-97d3-43303fffbf56",
        filter_type: "2",
      }),
    },
    {
      headers: {
        "content-type": "application/x-www-form-urlencoded;charset=utf-8",
      },
    }
  )
  .then((result) => {
    console.log(result);
  });
这就是我得到的错误结果

(node:34480) UnhandledPromiseRejectionWarning: Error: Request failed with status code 403
    at createError (D:\reactjs\upload_lalal\server\node_modules\axios\lib\core\createError.js:16:15)
    at settle (D:\reactjs\upload_lalal\server\node_modules\axios\lib\core\settle.js:17:12)
    at IncomingMessage.handleStreamEnd (D:\reactjs\upload_lalal\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:34480) 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:34480) [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.

有人能给我解释一下为什么这是一个错误,以及如何修复它吗?谢谢。

您的错误是。。。HTTP 403,这意味着

 The HTTP 403 is a HTTP status code meaning access to the requested resource is forbidden

使用API是否需要访问令牌?

您的错误是。。。HTTP 403,这意味着

 The HTTP 403 is a HTTP status code meaning access to the requested resource is forbidden

您需要访问令牌才能使用API吗?

no bro,正如您在说明部分中所看到的,我只需要一个idno bro,正如您在说明部分中所看到的,我只需要一个id