Skip to content

[WIP]: Axios code generator #226

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

Closed
wants to merge 2 commits into from

Conversation

vibhorgupta-gh
Copy link
Contributor

@vibhorgupta-gh vibhorgupta-gh commented Mar 23, 2020

fixes #135

This creates a snippet for axios like so:

let axios = require('axios');
let options = {
   'method': 'get',
   'url': 'https://postman-echo.com/headers',
   'responseType': 'text',
   'headers': {
      'my-sample-header': 'Lorem ipsum dolor sit amet',
      'TEST': '@#$%^&*()',
      'more': ',./\';[]}{":?><|\\\\'
   }
};
axios(options).then(function (response) { 
   console.log(response.headers);
}).catch(function (error) {
   throw new Error(error);
});

The issue I'm facing is with the newman tests, can't seem to match the response of newman with the generates snippet. For example, in the test Request Headers (With special Characters), the follwoing happens:

This is the newman (and Postman) response in newmanResponses.json:

"headers": {
        "x-forwarded-proto": "https",
        "host": "postman-echo.com",
        "accept": "*/*",
        "accept-encoding": "gzip, deflate",
        "cache-control": "no-cache",
        "more": ",./';[]}{\":?><|\\\\",
        "my-sample-header": "Lorem ipsum dolor sit amet",
        "postman-token": "d9658ca3-4479-44ce-85ca-35ef488edcb7",
        "test": "@#$%^&*()",
        "user-agent": "PostmanRuntime/7.21.0",
        "x-forwarded-port": "443"
      }

and this is the response when an axios request is sent with the attached request headers (for the same test):

headers:
{ 'x-forwarded-proto': 'https',
     host: 'postman-echo.com',
     accept: 'application/json, text/plain, */*',
     more: ',./\';[]}{":?><|\\\\',
     'my-sample-header': 'Lorem ipsum dolor sit amet',
     test: '@#$%^&*()',
     'user-agent': 'axios/0.19.2',
     'x-forwarded-port': '443' } 

Clearly the response is being fetched, but somehow it is not exactly fetching the entire identical thing which is why newman test assertions are failing. Please advise @umeshp7 @shreys7 @shamasis

@shreys7
Copy link
Member

shreys7 commented May 5, 2020

@VibhorCodecianGupta The tests seem to be failing because the console statement is printing the output of the Axios code as [object object]. Can you replace the line to print JSON.stringify(response) so that the output can be of the useful form to compare?

@someshkoli
Copy link
Contributor

@VibhorCodecianGupta this might help.

@shreys7
Copy link
Member

shreys7 commented May 8, 2020

Updates @VibhorCodecianGupta ?

@Misiu
Copy link

Misiu commented May 26, 2020

#232 got merged so I think this can be closed.

@shreys7
Copy link
Member

shreys7 commented May 26, 2020

Closing this as #232 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can you please add the support for axios
4 participants