Skip to content
New issue

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

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

Already on GitHub? # to your account

node-XMLHttpRequest + axios + MockRequests: Cannot read property 'headers' of undefined #190

Open
d9k opened this issue Jul 29, 2021 · 1 comment

Comments

@d9k
Copy link

d9k commented Jul 29, 2021

D-Pow/mock-requests#15

global.fetch = require('node-fetch');
global.Headers = fetch.Headers;
global.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
MR = require('mock-requests');
global.axios = require('axios');

MR.setMockUrlResponse('http://localhost:1111/t', {
  mockExample: 1
});

axios.get('http://localhost:1111/t').then(resp => console.log(resp));
// Error "Cannot read property 'headers' of undefined"
// at exports.XMLHttpRequest.getAllResponseHeaders at node_modules/xmlhttprequest/lib/XMLHttpRequest.js:239`
d9k added a commit to d9k/node-XMLHttpRequest that referenced this issue Jul 29, 2021
@d9k
Copy link
Author

d9k commented Jul 29, 2021

Pull request:
#191

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

No branches or pull requests

1 participant