Response Data Controler

Is it possible to customize the return of an api in the controller using strapi v4? Make a map in its return?
thank you very much.

Is it not possible to change the json response of an endpoint?

I did it like below:

async find(ctx) {
       const response: any = await strapi.service('api::hero.hero').find({
           populate: ['image']
       const hero = [{
           'title': response.title,
           'image-default': response.image.url,
           'image-large': response.image.formats.large.url,
           'image-small': response.image.formats.small.url,
           'image-medium': response.image.formats.medium.url,
           'image-thumbnail': response.image.formats.thumbnail.url

       return hero;

You did it the right way, kind of.

Check the documentation for controllers.

You can also create a middleware for your route, in this you can intercept the request and amend any data you need to before it is returned.

Hope that helps!