coresmart / persistencejs

persistence.js is an asynchronous Javascript database mapper library. You can use it in the browser, as well on the server (and you can share data models between them).
http://persistencejs.org
1.73k stars 240 forks source link

Sync Feature with auth headers #181

Open dtelaroli opened 8 years ago

dtelaroli commented 8 years ago

How can I set auth headers before send data to server?

BLNorris commented 8 years ago

There doesn't seem to be a built in option for this, but you can add it manually in persistence.sync.js After the xmlHttp.open on lines 36 and 52 add a like like this

xmlHttp.setRequestHeader("Authorization",  YourAuthTokenHere);

You'll have to do something similar in the persistence.jquery.js if you are using it, as it overwrites these functions