Skip to content

Commit 5b69f55

Browse files
authored
🔧 fix: adjusts derive code snippet (#261)
The previous code won't compile because auth can be undefined, and would try to fire a `startsWith` on a non-object value.
1 parent e978c1c commit 5b69f55

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎docs/essential/context.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ new Elysia()
129129
const auth = headers['Authorization']
130130

131131
return {
132-
bearer: auth.startsWith('Bearer ') ? auth.slice(7) : null
132+
bearer: auth?.startsWith('Bearer ') ? auth.slice(7) : null
133133
}
134134
})
135135
.get('/', ({ bearer }) => bearer)

0 commit comments

Comments
 (0)