sst
sst copied to clipboard
Bug in minimal typescript starter: `event.requestContext` is not defined
I did the following:
npx create-sst@latest my-sst-app- chose 'minimal'
- chose 'minimal/typescript-starter'
cd my-sst-appnpm installnpx sst start- Opened up the SST console and invoked the lambda
The above steps resulted in the following error:
TypeError: Cannot read properties of undefined (reading 'time')
The offending line of code is this one:
body: `Hello, World! Your request was received at ${event.requestContext.time}.`,
because event.requestContext is undefined. In fact, event is an empty Object with no properties.
If I change the function signature from this:
export const handler: APIGatewayProxyHandlerV2 = async (event) => {
to this:
export const handler: APIGatewayProxyHandlerV2 = async (event, context) => {
Then I can see some request context information populated on the context object. It still doesn't have a property called time, though.
Technically that example is meant to just respond to an API request, as in you hit the API endpoint it generates. We should probably take it out since you can directly invoke the function like you did.