Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting diffrent response from axios and postman app #2858

Closed
someshkoli opened this issue Mar 28, 2020 · 1 comment
Closed

Getting diffrent response from axios and postman app #2858

someshkoli opened this issue Mar 28, 2020 · 1 comment

Comments

@someshkoli
Copy link

Describe the bug
While using axios i noticed that axios is giving different response as expected and as obtained in postman app. the data object had some additional parameters. i have added response obtained form both the applications below and also attached the collection and the code snippet i used to run the request.

To Reproduce
run the below code snippet on nodejs and then run the bellow collection in postman app and check the output result
postman collection

var axios = require('axios');
axios.post('https://postman-echo.com/post', {
  'headers': {
    'Content-Type': 'text/plain'
  },
  body: "Duis posuere augue vel cursus pharetra. In luctus a ex nec pretium. Praesent neque quam, tincidunt nec leo eget, rutrum vehicula magna.\nMaecenas consequat elementum elit, id semper sem tristique et. Integer pulvinar enim quis consectetur interdum volutpat. !@#$%^&*()_+-=,.<>/?"

}).then((response) => {
        console.log(response.data);
}).catch((err) => {
        console.log(err);
});

Expected behavior
to get response data as shown below

{
    "args": {},
    "data": "Duis posuere augue vel cursus pharetra. In luctus a ex nec pretium. Praesent neque quam, tincidunt nec leo eget, rutrum vehicula magna.\nMaecenas consequat elementum elit, id semper sem tristique et. Integer pulvinar enim quis consectetur interdum volutpat. !@#$%^&*()_+-=,.<>/?",
    "files": {},
    "form": {},
    "headers": {
        "x-forwarded-proto": "https",
        "host": "postman-echo.com",
        "content-length": "277",
        "accept": "*/*",
        "accept-encoding": "gzip, deflate",
        "content-type": "text/plain",
        "cookie": "sails.sid=s%3ATC0997qJdpy2gmQL6RVvVRXQmyCQy4O5.haigNLcMh0LprmXi6ohGYXkoinbBGyedKAHBJaCeyTo",
        "postman-token": "e439e42e-7a17-4021-9144-f47d1fb5a690",
        "user-agent": "PostmanRuntime/7.15.0",
        "x-forwarded-port": "443"
    },
    "json": null,
    "url": "https://postman-echo.com/post"
}

Response obtained

{ args: {},
  data:
   { headers: { 'Content-Type': 'text/plain' },
     body:
      'Etiam mi lacus, cursus vitae felis et, blandit pellentesque neque. Vestibulum eget nisi a tortor commodo dignissim.\nQuisque ipsum ligula, faucibus a felis a, commodo elementum nisl. Mauris vulputate sapien et tincidunt viverra. Donec vitae velit nec metus.' },
  files: {},
  form: {},
  headers:
   { 'x-forwarded-proto': 'https',
     host: 'postman-echo.com',
     'content-length': '308',
     accept: 'application/json, text/plain, */*',
     'content-type': 'application/json;charset=utf-8',
     'user-agent': 'axios/0.19.2',
     'x-forwarded-port': '443' },
  json:
   { headers: { 'Content-Type': 'text/plain' },
     body:
      'Etiam mi lacus, cursus vitae felis et, blandit pellentesque neque. Vestibulum eget nisi a tortor commodo dignissim.\nQuisque ipsum ligula, faucibus a felis a, commodo elementum nisl. Mauris vulputate sapien et tincidunt viverra. Donec vitae velit nec metus.' },
  url: 'https://postman-echo.com/put' }

Environment:

  • Axios Version [e.g. 0.18.0]
  • OS:Linux Kali 5.3.0-kali2-amd64 Abstract XHR to node's http #1 SMP Debian 5.3.9-3kali1 (2019-11-20) x86_64 GNU/Linux
  • Additional Library Versions [e.g. React 16.7, React Native 0.58.0]

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

@chinesedfan
Copy link
Collaborator

When sending post requests, notice that the second parameter is data, instead of axios config. See more in my notes.

@axios axios locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants