Skip to content

Migration away from withIronSessionApiRoute #769

Closed Answered by vvo
elie222 asked this question in Q&A
Discussion options

You must be logged in to vote

Yep this is how it was done previously:

export function withIronSessionApiRoute(
handler: NextApiHandler,
options: IronSessionOptions | GetIronSessionApiOptions,
): NextApiHandler {
return async function nextApiHandlerWrappedWithIronSession(req, res) {
let sessionOptions: IronSessionOptions;
// If options is a function, call it and assign the results back.
if (options instanceof Function) {
sessionOptions = await options(req, res);
} else {
sessionOptions = options;
}
const session = await getIronSession(req, res, sessionOptions);
// we define re…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by vvo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #679 on June 14, 2024 13:21.