Skip to content

Commit

Permalink
Fix json body parse example
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelrenanpacheco committed Nov 24, 2018
1 parent ceeab29 commit c03bdb0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -62,7 +62,7 @@ Let's assume you are building a JSON API to process a payment:
# handler.js

const middy = require('middy')
const { urlEncodeBodyParser, validator, httpErrorHandler } = require('middy/middlewares')
const { jsonBodyParser, validator, httpErrorHandler } = require('middy/middlewares')

// This is your common handler, in no way different than what you are used to doing every day
// in AWS Lambda
Expand Down Expand Up @@ -98,7 +98,7 @@ const inputSchema = {

// Let's "middyfy" our handler, then we will be able to attach middlewares to it
const handler = middy(processPayment)
.use(urlEncodeBodyParser()) // parses the request body when it's a JSON and converts it to an object
.use(jsonBodyParser()) // parses the request body when it's a JSON and converts it to an object
.use(validator({inputSchema})) // validates the input
.use(httpErrorHandler()) // handles common http errors and returns proper responses

Expand Down

0 comments on commit c03bdb0

Please sign in to comment.