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

mapping the response #325

Closed
Kikobeats opened this issue Dec 28, 2020 · 0 comments
Closed

mapping the response #325

Kikobeats opened this issue Dec 28, 2020 · 0 comments

Comments

@Kikobeats
Copy link

Hello,

const app = function (req, res) {
  res.end('hello world')
}

const server = serverlessExpress.createServer(app)

exports.handler = async (event, context) => {
  const result = await serverlessExpress.proxy(server, event, context)
  console.log(result)
  return result
}

being the response:

{
  "statusCode": 200,
  "body": "hello world",
  "headers": {
    "date": "Mon, 28 Dec 2020 10:50:26 GMT",
    "connection": "close",
    "content-length": "11"
  },
  "isBase64Encoded": false
}

However, as you can see on my code intention, I'm just interested in exposing body.

That's happening essentially because the default behavior is to expose all the information:

https://github.com/vendia/serverless-express/blob/master/src/index.js#L91

could be possible to provide a way to map the response? something like:

 const result = await serverlessExpress.proxy(server, event, context, {
  responseMapper: ({ body }) => body
 })
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

1 participant