© Christopher Pitt 2018
Christopher PittThe Definitive Guide to AdonisJshttps://doi.org/10.1007/978-1-4842-3390-0_5

5. Responses

Christopher Pitt1 
(1)
Cape Town, Western Cape, South Africa
 

In the previous chapter, we learned about requests. The flip side of that coin is responses. For each request that demands something of our application, a well-crafted JSON, XML, or HTML response is the answer. Perhaps the request is for a list of users or an API authentication. In this chapter, let’s learn the ins and outs of responses.

Sending Simple Responses

We’ve already seen several ways to respond to HTTP requests. We started off by returning strings from our route closures. These strings were then rendered as HTML responses in the browser.

We reused this idea ...

Get The Definitive Guide to AdonisJs: Building Node.js Applications with JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.