Comments (3)
This is how I got stocks.js to work on my setup using VueJS.
require('stocks.js')
const stocks = new Stocks('YOUR_API_KEY')
module.exports = {
fetchData: symbol => {
const options = {
symbol: symbol,
interval: '1min',
amount: 1
}
return stocks.timeSeries(options)
}
}
Where here I export the fetchData function and can pass it a symbol to then have it return the data.
However, I don't necessarily like having to use commonjs require statements as it throws this warning on webpack, Critical dependency: the request of a dependency is an expression
.
Is there a way to not use the commonjs require with stocks.js and instead use ES6 import, but what would we be importing since import stocks from 'stocks.js'
is not correct since you can't do stocks.Stocks('API_KEY')
So I think me and @ilkertuna are looking for the correct way to use stocksjs with ES6 imports as the examples look more focused on just <script>
tag usage.
from stocks.js.
Actually, it looks like PR #6 might solve this issue whenever that gets merged
However, until that gets resolved, what I've done, is placed the dist/stocks.js
file in the static folder and then used a <script>
tag in my index.html. This allows me to remove the require('stocks.js')
, and avoids the webpack related error since stocks.js
will be made available before I'm using it in my VueJS bundled application.
Maybe this will help someone with a similar issue regarding using stocks.js in webpack dependent projects.
from stocks.js.
please add this to the ReadMe file it took me 30 minutes to figure out you have to do require('stocks.js') not require('stocks')
from stocks.js.
Related Issues (20)
- XMLHttpRequest require to use node target in webpack HOT 6
- stocks.js as name is not recommended HOT 1
- timeSeries does not work HOT 1
- nodejs broken HOT 2
- Use URL.searchParams HOT 1
- Error hashtable HOT 1
- Invalid Date in Firefox HOT 2
- Alphavantage removed intraday data for interval like 1min, 5min, hourly etc HOT 4
- Please generate ES5 code in dist
- node-fetch in browser environments HOT 1
- stock requests only meet 2/3 of data points HOT 2
- TypeError: this._throw is not a function HOT 3
- More intervals
- Stocks is not a constructor HOT 3
- Get current stock price? HOT 6
- how do I display company name to my page
- Readme RE: not currently hosting JS HOT 1
- jsfiddle retrieve not working
- @types/stocks.js for typescript support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stocks.js.