Storing data from facebook login

From the facebook login example: https://github.com/fusetools/fuse-samples/blob/master/Samples/FacebookLogin/MainView.js

function getMe(){
	var url = "https://graph.facebook.com/v2.5/me?fields=name&";
	url += "access_token=" + accessToken.value;

	fetch(url,{
		method:"GET"
	}).then(function(result){
		return result.json();
	}).then(function(resultJson){
		myName.value = resultJson.name;
	}).catch(function(error){
		console.log("Error: " + error);
	}); ```

Im trying to perserve myName with some sort of:

```router.goto("nextPage", myName);```

but it doesnt work because im dumb :)

Exactly what happens when you try this?

One issue could be that myName is an observable (which isn’t serializable and thus not allowed as a routing parameter), but in that case you should get a fairly self-explanatory error message.

Im pretty sure it just stays undefined i tried it like this:

var test = "test1.";
function getMe(){
  var url = "https://graph.facebook.com/v2.5/me?fields=name&";
  url += "access_token=" + accessToken.value;

  fetch(url,{
    method:"GET"
  }).then(function(result){
    return result.json();
  }).then(function(resultJson){
    myName.value = resultJson.name;
    userInfo.add(myName);
    test = resultJson.name;
  }).catch(function(error){
    console.log("Error: " + error);
  });

and passed test to the next page:

function gotoOrder(){
  router.goto("OrderPage", test);
}

and the data binding is still “test1.” when I:

<Text Value="{test}"/>

The data binding for myName works perfect on the login page though, I also tried an approach with an observable with userInfo.add(myName); but then there was no text, so probably undefined

and the data binding is still “test1.” when I [ … ]

This could be because the UI for the 2nd page is initialized before the test variable is updated. (And since it’s not an observable the update isn’t passed on to the UI).

Anyway, please refer to these docs on how you should be handling parameter passing: Fuse

Effectively what you have to make sure of is:

  • You only pass serializable data as a routing parameter
  • In the page that receives the parameter you can use it to set local observables, which are then data bound to your local ux.