Having discussed an example of a before handler above, let's next look at the implementation of an after handler.
After handlers are executed after the on handlers and are often used to enrich outbound data.
As an example, we will create an after handler for our CatalogService: We want to grant a discount of 11% for books with a stock of more than 200. For this purpose, the character string " -- 11% Discount!" is to be appended to the title of all books whose stock exceeds 200 via an after handler.
We proceed in the same way as with the implementation of the before handler. In other words, we create a file called cat-service.js in the srv folder of our project, as this folder also contains the file cat-service.cds, which is used to define the CatalogService (see following figure).

Analogous to what we discussed with the before handler, we create a subclass of cds.ApplicationService in the cat-service.js file, which we call CatalogService.
To manipulate the book title, we now need an after handler, which should be registered for READ operations on the Books entity. To do this, we overwrite the inherited init() method in the created implementation class (see following figure).

To register an after handler in the init() method, call the inherited after() method via this.after(). The after() method has the following interface. A detailed description of the individual parameters can be found in the CAP documentation.
12345function after (
event : string | string[] | '*',
entity? : CSN definition | CSN definition[] | string | string[] | '*',
handler : function
)
In the example shown, we register the named function this.grantDiscount for READ operations on the Books entity. To do this, we proceed analogously to the registration of the before handler discussed above.