AshMartian / carwings

Javascript library for the Nissan Leaf Carwings JSON API
MIT License
0 stars 2 forks source link

batteryStatusCheck return error #3

Open fab33 opened 7 years ago

fab33 commented 7 years ago

With this code :

var carwings = require('carwings');

carwings.loginSession('login', 'password', 'NE').then(function(session){
  //Get cached current LEAF status
  carwings.batteryStatusCheck(session).then(function(status){   
    console.log(status);
  });
});

I have a lot of date and at the end :

  data: 
   { status: '-6000',
     ErrorCode: '-6000',
     ErrorMessage: 'BadRequest' } }
Error: BadRequest
    at /home/furax/node_modules/carwings/lib/index.js:17:13
    at Generator.next (<anonymous>)
    at step (/home/furax/node_modules/carwings/lib/index.js:42:191)
    at /home/furax/node_modules/carwings/lib/index.js:42:361
    at process._tickCallback (internal/process/next_tick.js:103:7)

First I think there was an error in L114 and change to :

const batterystatuscheck = session => longpollrequest('BatteryStatusCheckRequest', 'BatteryStatusCheckResultRequest', session);

because compraing to pycarwings, I think first we hav to call BatteryStatusCheckRequest before BatteryStatusCheckResultRequest But always the same error (work with pycarwings2 example) My knowledge with JS is too poor to understand why it doesn't work !