feedback icon indicating copy to clipboard operation
feedback copied to clipboard

[Bug]: Axios request snippet badly generated with Form URL-Enconded

Open corderop opened this issue 3 years ago • 0 comments

What happened?

When the Request created is using Form URL-Encoded body type, the Javascript Axios code is badly generated. The code generated will be using JSON body type instead of the correct one. In fact, the code generated when JSON body type is selected is the same.

Steps to reproduce?

  1. Create a POST request
  2. In the body tab, select Form URL-Encoded type
  3. Add some parameters in the body
  4. Click in the snippet code generation for Javascript Axios
  5. The code generated will be like this:
import axios from "axios";

const options = {
  method: 'POST',
  url: 'https://url.com',
  data: {
    grant_type: 'authorization_code',
    code: 'code',
    redirect_uri: 'http://localhost/'
  }
};

axios.request(options).then(function (response) {
  console.log(response.data);
}).catch(function (error) {
  console.error(error);
});
  1. If you run the code, you will see that the request content-type is application/json

VS Code version

1.70.0

Extension version

v1.4.1

Relevant log output

No response

corderop avatar Aug 23 '22 18:08 corderop