Get error when try to post to another domain

442 views Asked by At

I'm trying to post form-urlencoded in Axios

This is my code

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);
  });

This what I got

(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.

Can anyone explain to me what is the error and how to fix it? thanks :D

1

There are 1 answers

0
Kevin Guebert On

In the error response it states Request failed with status code 403. 403 usually means "Forbidden" and that you do not have access to perform that request. I would check to make sure you have any access keys, tokens, or authorization required to make that request.

403 Forbidden: The server understood the request, but is refusing to fulfill it. (Source)