Comments (5)
The request header doesn't appear to specify a content-type? I think bodyparser is probably causing it. What happens if you remove bodyParser? do you see the body as a string?
from serverless-http.
Hi @dougmoscrop Thanks for your reply.
I have rem // app.use(bodyParser());
, but got same result
Note: Nodejs8.10
I write some dummy code and testing with api-gateway, it can response body as my request
function respBuilder(statusCode = 200, body = '') {
return {
statusCode,
body: JSON.stringify(body)
};
}
exports.handler = async (event) => {
if (!event.body) {
return respBuilder(400, "Bad request nha may");
}
// TODO implement
return respBuilder(200, event.body)
};
from serverless-http.
Having the same issue with express.js
too.
from serverless-http.
Found the culprit, if you use express.js
>= v4, you have to app.use(require('body-parser').json())
to parse request body.
Taken from the following resource:
from serverless-http.
yeah there are numerous tests, and deployed apps, that are using body-parsing of json, I'm pretty sure this works unless you don't specify a content-type header (which is how it always works)
from serverless-http.
Related Issues (20)
- When using ALB and Lambda with multi value headers, regular headers are not being added to the multiValueHeaders object HOT 6
- Receiving null from lambda HOT 5
- serverless-http examples for Loopback HOT 1
- Using this library with AWS function URLs? HOT 3
- body-parser middleware not triggering in Express 5/body-parser 2.x HOT 2
- Cannot work with graphql, express-graphql or graphql-http
- Multiple `set-cookie` don't end up in the final response when an ALB is the trigger
- Integration with websockets HOT 1
- gRPC connect-es support
- Double logging since v3.1.1 HOT 1
- Is there a way to disable or replacing logging? HOT 1
- Xmlrpc support ? HOT 7
- How to properly wrap the http.createServer? HOT 4
- Streaming response HOT 5
- Use with Serverless Dashboard V2.0 and CLI V3 HOT 4
- {"message":"Missing Authentication Token"}
- Support Elysia.js
- Buffer in request.body
- Catch-all error handling with API GW?
- Is this repo still being maintained? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serverless-http.