mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 19:36:20 +00:00
Fix relationships request
This commit is contained in:
parent
0e26dc48e9
commit
112a956bab
@ -44,7 +44,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch and format value
|
// Fetch and format value
|
||||||
const value = this.fetchValue(ctx, object).toJSON() || this.fetchValue(ctx, object);
|
const value = this.fetchValue(ctx, object);
|
||||||
|
|
||||||
if (!_.isEmpty(value)) {
|
if (!_.isEmpty(value)) {
|
||||||
ctx.response.body = yield this.serialize(ctx, type, object, value, matchedRoute);
|
ctx.response.body = yield this.serialize(ctx, type, object, value, matchedRoute);
|
||||||
@ -295,7 +295,7 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
fetchValue: function (ctx, object) {
|
fetchValue: function (ctx, object) {
|
||||||
const data = ctx.body;
|
const data = ctx.body.toJSON() || ctx.body;
|
||||||
|
|
||||||
switch (object) {
|
switch (object) {
|
||||||
case 'collection':
|
case 'collection':
|
||||||
@ -319,7 +319,7 @@ module.exports = {
|
|||||||
return data[ctx.params.relation];
|
return data[ctx.params.relation];
|
||||||
}
|
}
|
||||||
|
|
||||||
return _.first(data[ctx.params.relation]) || data[ctx.params.relation];
|
return data[ctx.params.relation] || _.first(data[ctx.params.relation]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user