Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sls webpack serve does not pass POST data to event.body #121

Closed
fwang opened this issue May 3, 2017 · 4 comments
Closed

sls webpack serve does not pass POST data to event.body #121

fwang opened this issue May 3, 2017 · 4 comments

Comments

@fwang
Copy link

fwang commented May 3, 2017

Steps to reproduce

  1. run sls webpack serve
  2. curl http://localhost:8000/hello -d "hello world"
  3. event.body is { }

Lambda function

export const hello = async (event, context, callback) => {
  const response = {
    statusCode: 200,
    body: event.body
  };

  callback(null, response);
};

Serverless.yml

...
functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: hello
          method: post
@franciscocpg
Copy link
Member

hi @fwang
I was facing the same problem.
After taking a look at the code I realized that we must pass content-type: application/json" header.
So in your case
curl http://localhost:8000/hello -H "content-type: application/json" -d '{"hello": "world"}'.
Data must be a valid JSON

@HyperBrain
Copy link
Member

@franciscocpg @fwang If you use the serve functionality, it would be great if you could comment in #135 .

@franciscocpg
Copy link
Member

I'm using serverless-offline too

@HyperBrain
Copy link
Member

serve will be removed in the next v3.0.0 release in favor of serverless-offline (see #152 ). No efforts will be spent on the function anymore. So I'll close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants