@mathieuc/tradingview 3.5.0 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mathieuc/tradingview",
3
- "version": "3.5.0",
3
+ "version": "3.5.1",
4
4
  "description": "Tradingview instant stocks API, indicator alerts, trading bot, and more !",
5
5
  "main": "main.js",
6
6
  "scripts": {
@@ -428,10 +428,11 @@ module.exports = {
428
428
  * @returns {Promise<User>} Token
429
429
  */
430
430
  async getUser(session, signature = '', location = 'https://www.tradingview.com/') {
431
- const { data } = await axios.get(location, {
431
+ const { data, headers } = await axios.get(location, {
432
432
  headers: {
433
433
  cookie: genAuthCookies(session, signature),
434
434
  },
435
+ maxRedirects: 0,
435
436
  validateStatus,
436
437
  });
437
438
 
@@ -457,6 +458,10 @@ module.exports = {
457
458
  };
458
459
  }
459
460
 
461
+ if (headers.location !== location) {
462
+ return this.getUser(session, signature, headers.location);
463
+ }
464
+
460
465
  throw new Error('Wrong or expired sessionid/signature');
461
466
  },
462
467