Skip to content

Commit

Permalink
Add getDrawings function example
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu2301 committed Mar 5, 2022
1 parent 6719507 commit 945a8ca
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions examples/GetDrawings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const TradingView = require('../main');

/*
This example tests the
getDrawings function
*/

// First parameter must be the layoutID
// (if the layout is private) Second parameter must be the sessionid cookie
// (if the layout is private) Third parameter must be the userid (you can use getUser function)

if (!process.argv[2]) throw Error('Please specify a layoutID');

TradingView.getDrawings(process.argv[2], null, {
session: process.argv[3],
id: process.argv[4],
}).then((chartToken) => {
console.log(`Found ${chartToken.length} drawings:`, chartToken.map((d) => ({
id: d.id,
symbol: d.symbol,
type: d.type,
text: d.state.text,
})));
}).catch((err) => {
console.error('Error:', err.message);
});

0 comments on commit 945a8ca

Please sign in to comment.