1

I have a lambda function defined as

getDta:
    handler: src/handlers/data/get.getAll
    events:
      - http:
          path: groups/{groupsId}/data
          method: get
          cors: true
          private: true

If I use API like http://localhost:3000/groups//data where groupsId is missing from path please take a look again.

In this case serverless itself return 404 - Route not found. How can I override this error to 400 - Bad request?

I appreciate your suggestion! (edited)

1 Answer 1

1

You could create a function for path: groups/data and return 400 - Bad Request. But 404 is not a Bad Request code.

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

4 Comments

Sorry for the typo, It should be 400 - Bad request, I have edited question description
Is it really a good idea? Is there no any cleaner way? Is there nothing like configuration in serverless.yml?
And it is not like path: groups/data as you mentioned but it is like path: groups//data.
There is a catch all aws.amazon.com/blogs/aws/…

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.