Skip to content

Commit 3594cdf

Browse files
fix undefined id in relationship link url
1 parent e48e6fe commit 3594cdf

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/serializer.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,10 @@ function parseRelations (data, relations, options) {
114114

115115
_.each(relations, function (relation, name) {
116116

117-
var pkName = relation.keyFrom;
118117
var fkName = relation.keyTo;
119118

120-
// If relation is belongsTo then pk and fk are the other way around
119+
// If relation is belongsTo then fk is the other way around
121120
if (relation.type === 'belongsTo' || relation.type === 'referencesMany') {
122-
pkName = relation.keyTo;
123121
fkName = relation.keyFrom;
124122
}
125123

@@ -134,7 +132,7 @@ function parseRelations (data, relations, options) {
134132
return false;
135133
}
136134

137-
var pk = data[pkName];
135+
var pk = data[options.primaryKeyField];
138136
var fk = data[fkName];
139137

140138
var fromType = utils.pluralForModel(relation.modelFrom);

0 commit comments

Comments
 (0)