2021-04-06 16:08:59 +08:00

11 lines
342 B
JavaScript

import { isObject } from './helpers';
export default async (ctx, next) => {
const dataField = ctx.config.dataField ?? ctx.dataField;
if (ctx.response && isObject(ctx.response.data) && dataField) {
ctx.response._rawData = ctx.response.data;
ctx.response.data = ctx.response.data[dataField];
}
await next();
};