9

Hooks and Error Handling

While it can be incredibly useful to make API requests from any page, imagine the nuisance of attempting to authenticate a user for an external API on every page. It may be possible to create a custom helper that adds specific headers or cookies to every single request to assist with this. Fortunately for us, SvelteKit provides methods to manipulate Request and Response objects across the entirety of a framework. It does so with what are called hooks. These hooks can be incredibly powerful to manage data that flows in and out of our application. They can also be helpful for managing errors. Since our previous encounters with error handling have been so brief, we’ll examine error handling a little closer after covering ...

Get SvelteKit Up and Running 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.