denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
98.07k stars 5.4k forks source link

Adding the data parameter to npm axios.request() or axios() fails with no errors #20123

Open arthemium opened 1 year ago

arthemium commented 1 year ago

While trying to run the below code, doesn't throw any errors, and doesn't continue into the sequence (doesn't print "AXIOS RESPONSE").

Removing, data parameter will resolve the issue.

Seems that the axios lib is not fully compatible with Deno

Tried to replace the version of axios with 1.3.0 and 1.2.0 (same results)

import axios from 'npm:axios@1.4.0';

(async () => {
try {
  const options = {
    "Authorization": "Basic ABC"
  }
  console.log("axios request");
  const axiosRes = await axios({
    url: 'http://localhost:3000',
    headers: options,
    method: 'POST',
    data: {"title": "blah"}
  });
  console.log("AXIOS RESPONSE")
  console.log(axiosRes)

} catch (error: any) {
  console.log("ERRROOROR")
  console.log(error);

}
})()
lino-levan commented 1 year ago

Cannot reproduce. I believe this is an issue with the server hosted on localhost. Could you share a public web server where this does happen?

arthemium commented 1 year ago

@lino-levan the issue is happening with the following url: https://ws.api.video/videos/123