Skip to content

Commit 4818ab3

Browse files
committed
fix(model): prevent calling identifier if relationship not a model
1 parent b590450 commit 4818ab3

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/lib/model.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,11 +493,17 @@ BaseModel.prototype.toJsonApi = function () {
493493

494494
if (Array.isArray(value)) {
495495
data.relationships![name] = {
496-
data: value.map((val) => val.identifier()),
496+
data: value.map((val) => ({
497+
type: val.type,
498+
id: val.id,
499+
})),
497500
};
498501
} else if (value) {
499502
data.relationships![name] = {
500-
data: value.identifier(),
503+
data: {
504+
type: value.type,
505+
id: value.id,
506+
},
501507
};
502508
} else {
503509
data.relationships![name] = {

0 commit comments

Comments
 (0)