I try to overwrite an ember-data model's save function:
models/client.js
export default DS.Model.extend({
billingAddress: DS.belongsTo('address'),
//...
save: function(...arg){
var _this = this;
this.get('billingAddress').then(billingAddress=>{
return billingAddress.save().then(function(){
return _this._super(arg);
});
})
}
});
Somewhere else I do
record.save().then(function(){
// show a message
});
I am getting the following error:
Uncaught TypeError: Cannot read property 'then' of undefined
SOLUTION
The main problem was that calling super
from a promise is not that straight forward, but is possible:
save: function(...arg){
let _super = this._super;
return somePromise.then(() => _super.call(this));
}