I have a function which create an entry in backend when an button ( save button ) is pressed.
Code for creating entry
var oModel = this.getModel('action');
oModel.create(path, body, {
success: this._onSuccess.bind(this), //How to pass response along with the bind function
error: this._onError.bind(this)
});
_onSuccess: function (response) {
// Response is not having any headers
//Show some success message
},
Instead of directly calling the function, I have binded the _onSuccess function to oModel.create’s success handler. From the backend I am sending some header parameters along the (POST) response, which I need to access inside the _onSuccess message and display.
When I directly include the function in success handler, I am able to see the response, but not sure how send it along the bind parameter
This is working
callCreate: function (path, body) {
var oModel = this.getModel('action');
oModel.create(path, body, {
success: function (data, response) {
//I am able to get the response headers here
},
error: this._onError.bind(this)
});
},