In my next app router project, I am trying to write an object to the Response with this function
async function writeSession<T>(session: T, response: Response) {
const dummyRequest = new Request('http://dummy')
const dummyResponse = new Response()
const ironSession = await getIronSession(
dummyRequest,
dummyResponse,
sessionOptions,
)
if (session) {
Object.assign(ironSession, session)
await ironSession.save()
} else {
await ironSession.destroy()
}
const cookieHeader = dummyResponse.headers.get('Set-Cookie')
if (cookieHeader) {
response = new Response(response.body, {
...response,
headers: {
...response.headers,
'Set-Cookie': cookieHeader,
},
})
}
return response
}
However I get the error on response = new Response
of
Assignment to function parameter 'response'.eslintno-param-reassign
(parameter) response: Response