Skip to content

Commit

Permalink
docs: add async to hook snippets to indicate they may return promises (
Browse files Browse the repository at this point in the history
  • Loading branch information
atuttle authored Apr 13, 2023
1 parent 208877d commit d6eca91
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions documentation/docs/30-advanced/20-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ For example, your `load` function might make a request to a public URL like `htt
```js
/// file: src/hooks.server.js
/** @type {import('@sveltejs/kit').HandleFetch} */
export function handleFetch({ request, fetch }) {
export async function handleFetch({ request, fetch }) {
if (request.url.startsWith('https://api.yourapp.com/')) {
// clone the original request, but change the URL
request = new Request(
Expand All @@ -124,7 +124,7 @@ If your app and your API are on sibling subdomains — `www.my-domain.com` and `
/// file: src/hooks.server.js
// @errors: 2345
/** @type {import('@sveltejs/kit').HandleFetch} */
export function handleFetch({ event, request, fetch }) {
export async function handleFetch({ event, request, fetch }) {
if (request.url.startsWith('https://api.my-domain.com/')) {
request.headers.set('cookie', event.request.headers.get('cookie'));
}
Expand Down Expand Up @@ -177,7 +177,7 @@ import crypto from 'crypto';
Sentry.init({/*...*/})

/** @type {import('@sveltejs/kit').HandleServerError} */
export function handleError({ error, event }) {
export async function handleError({ error, event }) {
const errorId = crypto.randomUUID();
// example integration with https://sentry.io/
Sentry.captureException(error, { event, errorId });
Expand Down Expand Up @@ -205,7 +205,7 @@ import * as Sentry from '@sentry/svelte';
Sentry.init({/*...*/})

/** @type {import('@sveltejs/kit').HandleClientError} */
export function handleError({ error, event }) {
export async function handleError({ error, event }) {
const errorId = crypto.randomUUID();
// example integration with https://sentry.io/
Sentry.captureException(error, { event, errorId });
Expand Down

0 comments on commit d6eca91

Please sign in to comment.