Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

I want to use the path param /customer/{customerId} of a GET request in order to query a customer using AWS Lambda:

functions:

  createCustomer:

    handler: handler.createCustomer

    events:

    - http:

        path: customer

        method: post

  readCustomer:

    handler: handler.readCustomer

    events:

    - http:

        path: customer

        method: get

How do I have to define the path param in order to pass it to my AWS Lambda function using serverless framework 1.0?

1 Answer

0 votes
by (44.4k points)

In serverless.yml, add this:

readCustomer:

  handler: handler.readCustomer

  events:

    - http:

        path: customer/{customerId}

        method: get

In code, you can access customerId

const customerId = event.pathParameters.customerId;

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...