2

How can I define the path in serverless.yml with more than one query parameter using HTTP API (API Gateway v2) so that the endpoint looks like the following:

https://example.com/rest/endpoint?id=$id&tag=$tag

serverless.yml

 dfsPostback: 
    handler:  handlers/result.main 
    events:
      - httpApi:
          path: /dfs-pingback  // need help here 
          method: get

I tried with

path: /dfs-pingback?id={id}&tag={tag}

deployment failed

1
  • 1
    you dont need to specify query strings in the path. however path parameters will need to. they. will be sent in the event object Commented Jul 5, 2022 at 6:54

1 Answer 1

3

There is no need to specify the query parameters in the path. You should be able to access all passed query params in your event handler.

Sign up to request clarification or add additional context in comments.

1 Comment

I just want to add that, you can read event.queryStringParameters (object) containing your params, but if no param is provided then event.queryStringParameters (null), so make sure to check type first before destructuring or reading properties.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.