Have 'undefined' on changed variable...

var Observable = require('FuseJS/Observable');
var token = Observable("");
var frnd = Observable();
var url;
this.Parameter.onValueChanged(function(args) {
	token.value =  args;
});
url = "https://api.vk.com/method/friends.get?";
url += "access_token=" + token.value + "&fields=photo_200&order=hints";
fetch(url)
.then(function(res) {
	return res.json();
})
.then(function(resJson) {
	frnd.value = resJson;
	console.log("frnd 1 is " + JSON.stringify(frnd.value))
})
.catch(function(err) {
	console.log("ero: " + err);
})
console.log("frnd 2 is " + JSON.stringify(frnd.value));

now look log:

LOG: frnd 2 is undefined
LOG: frnd 1 is {"response":[{"uid":298682753,"first_name":...next_info.....

Hi!

The reason you’re getting this is that fetch returns a Promise (which is a standard you can read about here https://promisesaplus.com/).

What this means is that by the time your code evaluation reaches the last line (where you console.log("frnd 2 ...), we still haven’t evaluated the result of the fetch. This is because fetch is asynchronous, and the result of it will happen later.