I am making a api with netlify functions, i am using serverless-http and netlify-lambda to build it with express. How can I access the context var in api request?
Are you talking about netlify-lambda
npm package? If yes, you need to stop using it as it’s not required anymore.
About your question, this should work (in TypeScript):
import type {HandlerContext, HandlerEvent} from '@netlify/functions'
import type {Request, Response} from 'express'
import express from 'express'
export async function handler(event : Event, context: Context) {
const app = express()
return serverless(app)(event, context)
}
Thank you for informing me about netlify-lambda
and context