Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Getting Started with hapi.js

You're reading from  Getting Started with hapi.js

Product type Book
Published in Apr 2016
Publisher
ISBN-13 9781785888182
Pages 156 pages
Edition 1st Edition
Languages

The reply interface


In the various life cycle events in hapi, such as authentication, route handlers, route prerequisites, you will see reply as one of the function arguments. This is the reply interface.

Throughout this book and the API documentation, you will see the function reply in two forms—either as reply() or as reply.continue()—which have two different purposes. reply.continue() is generally used to return the control flow back to the framework and continue through the request life cycle, whereas reply() is generally used to generate the response to be returned to the client. The only exception to this is inside the route prerequisites where reply() is used, as it assigns a variable to the request.pre object.

reply() can accept two parameters (error and response), but this is rarely used, as reply always acts on the first defined parameter that it is passed in. For example, if reply() is passed two variables and the first one is not null, it treats this as an error reply. If only...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}