Steaming Lambda Function "setContentType is not a function" #12090
-
I'm attempting to stream data using my Lambda function deployed using Any help or advice would be greatly appreciated. I've spent a couple of days researching but haven't really found anything that has helped here. Example: exports.handler = awslambda.streamifyResponse(
async (event, responseStream, context) => {
responseStream.setContentType('text/plain');
responseStream.write('Hello, world!');
responseStream.end();
}
); My app: sls
service: sls
frameworkVersion: '3'
provider:
name: aws
runtime: nodejs18.x
region: eu-west-1
timeout: 30
functions:
api:
handler: index.handler
layers:
- !Ref ApiLambdaLayer
url:
invokeMode: RESPONSE_STREAM
events:
- httpApi:
path: /
method: get
layers:
api:
package:
artifact: ./resources.zip |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I have this same error for a non-function URL based lambda but in your case, for function url based lambdas, you need to call:
|
Beta Was this translation helpful? Give feedback.
-
Hi! What should I do to be able to use the "awslambda" object/package/whatever? What is it? If I type it, it is unknown, and I find nothing about it. Thanks! |
Beta Was this translation helpful? Give feedback.
I have this same error for a non-function URL based lambda but in your case, for function url based lambdas, you need to call:
See: https://docs.aws.amazon.com/lambda/latest/dg/response-streaming-tutorial.html#response-streaming-tutorial-create-functi…