jeremydaly / lambda-api

Lightweight web framework for your serverless applications
https://serverless-api.com
MIT License
1.41k stars 125 forks source link

Response is not as expected, the body has a body property but is not the actual body #252

Closed lfmunoz closed 8 months ago

lfmunoz commented 8 months ago
app.get('/admin/test', async (req, res) => {
  const result = await test.queryDocuments(req.query);
  res.status(result.status).send(result.body);
});

does not return the expected result

it returns the body of:

{
  "headers": {
    "content-type": "application/json",
    "access-control-allow-origin": "*",
    "access-control-allow-methods": "GET, PUT, POST, DELETE, OPTIONS",
    "access-control-allow-headers": "Content-Type, Authorization, Content-Length, X-Requested-With"
  },
  "body": "{\"currentPage\":1,\"pageSize\":25,\"totalResults\"
  "isBase64Encoded": false
}

But the expected body is

{"currentPage\":1,\"pageSize\":25,\"totalResults ...

can't figure out how to send just the body

lfmunoz commented 8 months ago

Never mind figured out it does that when status is undefined. Kinda tricky don't think that is the best default behavior.