Refector Typescript code to convert JSON api to CSV [duplicate]

I have a project in Node JS with Typescipt in which I have a class that receives a JSON from an api and converts it to CSV format.
The problem is that I have all the code in the main controller, I am trying to refactor the code but I don’t…