How to set common api response structure for all APIs

Hi @DMehaffy thanks for your response. I tried achieving this using middleware but as you mentioned its also modifying request for Admin panel. Can you please suggest how can I avoid middleware to execute for Admin panel requests.
My middleware:

    return {
        initialize() {
            strapi.app.use(async (ctx, next) => {
                let response = {};
                await next();
                if (ctx.response.status === 200) {
                    response.status = 'success';
                    response.data = ctx.response.body;
                }
                else {
                    response.status = 'error';
                }
                ctx.response.body = response;
            });
        },
    };
};
1 Like