Closed riteshdalal closed 10 years ago
This feature has already been implemented:
see: https://github.com/viezel/napp.alloy.adapter.restapi/blob/master/restapi.js#L154-L161
and: https://github.com/viezel/napp.alloy.adapter.restapi/blob/master/restapi.js#L91-L94
I'm sorry didn't see this. Could you please give me some example code? Not sure how to do this dynamically. Thanks :+1:
@nicka Check out the link below for example. https://github.com/riteshdalal/napp.alloy.adapter.restapi
You can also create each of the header properties as a function instead of a static value
headers : {
"Cookie" : function(){
//calculate a dynamic cookie value and set it
var cookie_value = someFunctionThatFetchesIt();
return "cookie_name="+cookie_value;
}
}
@viezel There is a slight difference in what you provided and what I implemented. It is an enhancement that lets you create dynamic headers without knowing all the headers to set ahead of time and using what you pointed out, the headers could be a nested object
@riteshdalal @viezel managed to get it working. Didn't update to 1.1.5 yet. :see_no_evil:
@riteshdalal i dont follow. I cannot see how yours are more dynamic. You can do the following with my implementation
myModel.save({}, {
headers : {
"Cookie" : function(){
var cookie_value = someFunctionThatFetchesIt();
return "cookie_name="+cookie_value;
},
"AlloyUser": Alloy.Globals.getUserAPIKey();
}
}
:+1: