balena-io / balena-sdk

The SDK to make balena powered JavaScript applications.
https://www.balena.io/
Apache License 2.0
145 stars 46 forks source link

Setting and getting apiUrl doesn't behave as expected #501

Open imrehg opened 6 years ago

imrehg commented 6 years ago

In this piece of code I set the API URL to one value, then query that value:

var myApiUrl = "https://api.resinstaging.io"
const resin = require('resin-sdk')({
    apiUrl: myApiUrl
})
console.log(`My : ${myApiUrl}`)
resin.settings.get('apiUrl').then(function(apiUrl) {
    console.log(`Set: ${apiUrl}`);
});

and the output is:

$ node test.js                   
My : https://api.resinstaging.io
Set: https://api.resin.io

instead of both values being the same.... On the other hand resin object uses the correct endpoint for further queries, at least it seems to...

Is this expected? Or not the required behaviour?

thgreasi commented 6 years ago

I was only able to find a single set operation on the settings storage that takes place inside the setKey() method of resin-auth.