I have a login form using ajax-form "submitted" event. Based on this I'm 
trying to set a cookie with a session value provided by the server and use 
this in the header of a subsequent iron-ajax call. But, the execution 
sequence is not the one I was hoping: function inside evenlistener is 
executed only at the end so my ajax call is done without the proper header. 
The header value is computed on the sessionid value change.

                Properties{ 
                          headers: {
type: Object,
computed: 'getHeaders(sessionid)'
}, 
                               sessionid: {
                                    type: String,
                                    value: ''
                                }
}
                          getHeaders: function(customHeader) {
        return {'Token': customHeader}
},

                     _submitOnLogin: function(event) {
this.user = this.$.username.value;
this.pass = this.$.password.value;
var content = this.$$("#loginForm");
content.action = '/api/v1/sessions/login';
content.addEventListener('submitted', this.setCookie); //where I'm getting 
the session value and change my sessionid 

this.$$("#loginForm").submit();  //I was hoping the setCookie function will 
be executed here 

                                this._loadAppProfiles(); // triggering the 
iron-ajax call

},

                setCookie: function(event) {
          if (event.detail.status==200) {
var response=JSON.parse(event.detail.response);
sessionid = response["sessionToken"];
this.sessionid=sessionid;}
                },

                     _loadAppProfiles: function(event) {
this.$.getprofile.generateRequest();
},

What am I missing - it's obvious it's something I wrongly presumed.
Thanks

Follow Polymer on Google+: plus.google.com/107187849809354688692
--- 
You received this message because you are subscribed to the Google Groups 
"Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/polymer-dev/42727987-41f3-4104-8e46-7037353b8e1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to