jeudi 12 février 2015

How can I modify a schema header

I am attempting to write an application using 5.1 and Parse.com.

When a user logs into the app, they are given a sessionToken. In order to use the REST API, I need to add that sessionToken to the model schema header. How can I modify the model schema header in run-time?


Currently my model schema looks like the code below. I have sessionToken as a global javascript var. Obviously that isn't working.



Code:



schema : {
id : 'users' ,
namespace : 'top.model' ,
proxy : {
type : 'rest' ,
url : 'http://ift.tt/1nKE0Gh' ,
useDefaultXhrHeader : false ,
withCredentials : false ,
headers : {
'X-Parse-Application-Id' : "xxxxxxxx" ,
'X-Parse-REST-API-Key' : 'xxxxxx' ,
'X-Parse-Session-Token' : sessionToken,
'Content-Type' : 'application/json'
},
reader : {
type : 'json' ,
rootProperty : 'results' ,
transform: function ( data ) {
return data.results ? data.results : {results :data};
}
},
writer : {
type : 'json' ,
writeRecordId : false
}
}
}





How can I modify a schema header

Aucun commentaire:

Enregistrer un commentaire