1

I'm building an app using ReactJS in the front-end and back-end as AWS API Gateway/AWS Lambda written in NodeJS. I'm passing the form data of my React app in the attribute called userAttributes like below:

enter image description here

I want to read this data in the backend logic. As per the Cloud Watch logs of Lambda, I'm getting the form data in the Lambda event as:-

  body: '------WebKitFormBoundarytTytoOIkcO2\r\n' +
    'Content-Disposition: form-data; name="userAttributes"\r\n' +
    '\r\n' +
    '[object Object]\r\n' +
    '------WebKitFormBoundarytTytrEkb0oOIkcO2--\r\n',
  isBase64Encoded: false
}

Here [object Object] is my Form data. How can parse and read this form data value? I can read my other query string parameters (event.queryStringParameters.<attributes>) but not sure how to read the form data.

1 Answer 1

1

Use https://www.npmjs.com/package/parse-multipart on your lambda and you can parse the data...

But first

  • Set the media type in you api gateway as multipart/form-data

  • When you added your lambda to the api gateway method please be sure if you check "proxy" because you need that to manage the data from the frontend as multipar/form-data

Sign up to request clarification or add additional context in comments.

1 Comment

thanks, API gateway is set to 'proxy' only. Thanks for the reference link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.