Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Use message instead of headers to get stock datas
  • Loading branch information
adwulfran committed Sep 14, 2020
1 parent ce5bff1 commit 1d434b8
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ Use stock symbol to receive datas. In this example we use EURUSD (forex), AAPL (
```javascript
const WebSocket = require('ws');
const ws = new WebSocket("wss:https://api.realtimefinance.io", {
headers: {
"API-X-KEY": "demo",
"symbol" : "EURUSD,AAPL,MSFT,MC.PA"
}
rejectUnauthorized: false // use only if you are behind a firewall
});

ws.on('message', function incoming(msg) {
console.log(msg);
const message = {
event: "subscribe",
data: ['EURUSD','GBPUSD','AAPL','MSFT']
};
ws.on("open", function open() {
ws.send(JSON.stringify(message));
});

ws.on("message", function incoming(data) {
console.log(data);
});
```

Expand Down

0 comments on commit 1d434b8

Please sign in to comment.