Skip to content

0.21.2 has a breaking change with pre-stringified JSON request body #4018

@kawanet

Description

@kawanet

Describe the bug

Since commit 5ad6994 in PR #3688 released with axios version 0.21.2,
it has a breaking change which forces to stringify the body even when pre-stringified in app.

To Reproduce

const axios = require("axios");
const body = "{}"; // pre-stringified JSON
const options = {headers: {"content-type": "application/json"}};
axios.post("http://127.0.0.1:3000/", body, options);
  • With 0.21.1, it sends a 2 byte request body {} to the server.
  • With 0.21.2, it sends a 4 byte request body "{}" to the server.

My app have a big post data which is already built by my app.
Axios should just send the body content pass through to the server.

Expected behavior

  • keep 0.21.1's behavior

Environment

  • Axios Version [e.g. 0.18.0]
  • Adapter [e.g. XHR/HTTP]
  • Browser [e.g. Chrome, Safari]
  • Browser Version [e.g. 22]
  • Node.js Version [e.g. 13.0.1]
  • OS: [e.g. iOS 12.1.0, OSX 10.13.4]
  • Additional Library Versions [e.g. React 16.7, React Native 0.58.0]

Additional context/Screenshots

  • Axios Version 0.21.1 and 0.21.2
  • Node.js Version 14.17.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions