fix: list data undefined error (#3905)

* fix: list data undefined error

* chore: typo
This commit is contained in:
ChengLei Shao 2024-04-03 09:17:20 +08:00 committed by GitHub
parent cc75f6f4d2
commit c22fc6f5d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -37,8 +37,19 @@ function createWithACLMetaMiddleware() {
// @ts-ignore
const primaryKeyField = Model.primaryKeyField || Model.primaryKeyAttribute;
const dataPath = ctx.body?.rows ? 'body.rows' : 'body';
let listData = lodash.get(ctx, dataPath);
let listData;
if (ctx.body?.data) {
listData = ctx.data;
} else if (ctx.body?.rows) {
listData = ctx.body.rows;
} else if (ctx.body) {
listData = ctx.body;
}
if (!listData) {
return;
}
if (actionName == 'get') {
listData = lodash.castArray(listData);