Closed kyrios closed 8 years ago
The intended behavior is to make the token available from outside the library. The token is not set until the first call to the vehicles() function so it has to be initialized as a null and then updated once the initial login occurs within the function called all(). I added another line to explicitly assign the retrieved token to export.token. I had assumed that the this happened automatically but I guess now. Should work now once I push the 1.0.3 version of Teslams.
Looking at teslams.js it seems to me as if the Authorization token should be accessible from outside the library and is therefore defined as an export. This is very useful to me since it allows caching and therefore avoiding an additional request to the TESLA API when only polling for example /charge_state.
However:
Unfortunately I think the '=' copies by value and not by reference. So when accessing the token from outside it is always an empty string.
I would submit a pull request that fixes the issue but wanted to make sure it is not intended behavior.