angular2-jsonapi icon indicating copy to clipboard operation
angular2-jsonapi copied to clipboard

Need change in save method

Open monkeycatdog opened this issue 6 years ago • 1 comments

JsonApiModel.prototype.save = function (params, headers, customUrl) {
  this.checkChanges();
  var attributesMetadata = this[AttributeMetadataIndex];
  return this.internalDatastore.saveRecord(attributesMetadata, this, params, headers, customUrl);
};

Good practice checkout arguments in function implementation, like a :

if (params instanceof HttpHeaders) {
  headers = params;
  params = {};
}

if (typeof headers === 'string'){
  customUrl = headers;
}

Without this check need set empty object for work headers, and if only need custom url, required add all arguments...

monkeycatdog avatar May 29 '19 09:05 monkeycatdog

I created simple implementation in this pull request

monkeycatdog avatar May 29 '19 09:05 monkeycatdog