component / model

Minimalistic extensible data models
122 stars 40 forks source link

allow setting custom headers on requests and handling of response. #43

Closed nw closed 11 years ago

nw commented 11 years ago

Adds Model.headers(Object) allowing for custom headers to be set on all requests.

Example:

User.headers({
  'X-CSRF-Token': 'some token',
  'X-API-Token': 'api token' 
});

This behavior is very helpful when working with 3rd party apis.

Having the ability to easily acquire the response object allows the ability to monitor api limits (ala github & twitter) and hook in caching mechanisms. As well as more robust error handling.

tj commented 11 years ago

perfect! thanks man