Skip to content

Commit 3715784

Browse files
committed
Refactor create to prepare for options argument
1 parent 6e7fdc2 commit 3715784

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Resource.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,14 @@ class Resource {
7474
return this.api.get(url).then(extractData).catch(extractErrorResponse);
7575
}
7676

77-
create(partialRecord) {
78-
const record = Object.assign({}, partialRecord, {type: this.name});
77+
create({attributes, relationships}) {
78+
const record = {type: this.name};
79+
if (attributes) {
80+
record.attributes = attributes;
81+
}
82+
if (relationships) {
83+
record.relationships = relationships;
84+
}
7985
const requestData = {data: record};
8086
return this.api
8187
.post(`${this.name}`, requestData)

0 commit comments

Comments
 (0)