Closed kresli closed 7 years ago
Hmm. I'm not sure why this is happening. Travis CI seems to handle it fine. Are you sure using the linked library would fix this? What node version are you using?
node -v
v8.1.3
I created a sample repo. https://github.com/kresli/stocks-js-test. You can test it with npm run build
Yep. Managed to reproduce it. I'm not really familiar with what target: 'node'
does specifically. But you might be right in that we need to seek a new request module.
I'm quite embarassed to say I never knew fetch
existed. If you're sure that this doesn't create any problems (and if you're sure it fixes the current one), please do switch from XMLHttpRequest to the listed library.
It seems to work like a charm (run from page with appropiate content security policy):
fetch('https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=MSFT&interval=1min&apikey=demo')
.then(function (response) {
return response.json()
}).then(function (body) {
console.log(body)
});
I made a version with fetch
. I tested it, and it seems to have fixed the problem :+1:
Follow this approach, it will solve the problem: https://github.com/webpack/webpack-dev-server/issues/66
I need to add
target: 'node'
to my webpack config otherwise I've got this errorI would suggest to use https://www.npmjs.com/package/whatwg-fetch. I can create a pull request