0

I've been googling for a few hours, and I need help. I dont think I'm using the correct words. Anyhow, I'm using Claudia.JS to set up a POST request to my AWS Lambda function. Here's the basics of the function:

api.post('/leads', function (request) {
   console.log(request);
   return request;
});

When I use postman to test the post request, I'm returned the request object. Awesome. Then I try to pass form-data through. I set the key to 'username' and the value to 'this is the username'. This is what request.body is:

"body": "---------------------------
-019178618034620042564575\r\nContent-Disposition: form-data; 
name=\"username\"\r\n\r\nthis is the username\r\n----------------------
------019178618034620042564575--\r\n",`

I thought I could return request.body.username... to key the value of username...but I'm missing something.

How do I access the form data in the request?

update: okay. The website is taking the form data, making a post request...this function is receiving the post request? still-- in postman...if I were to put my own JSON in...why can I not access request.body like... request.body.username?

Capella
  • 115
  • 1
  • 9

2 Answers2

2

You should try console.log(request.data) to see your request object, ie. in my own case I can see the content of my request's body.

Have a look at https://www.getpostman.com/docs/postman/scripts/postman_sandbox to see all the relevant information about your request.

A.Joly
  • 2,317
  • 2
  • 20
  • 25
  • inspecting it did the trick. I know it's been awhile, but I wanted to thank you for responding:) – Capella Jun 08 '18 at 23:06
0

I solved this by looking at the header set in postman. It was set to form-data instead of application/JSON. All gravy now.

Capella
  • 115
  • 1
  • 9