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