Search code examples
node.jsexpressbackendbody-parser

how to get a object that is in string inside the req.body in express?


I am trying to get the object from the frontend but the problem i am facing is that the fronend is sending that object in qoutes

Preview URL: false
[Object: null prototype] {
  name: 'Arun Teltia',
  email: 'acfsdzvff@gmail.com',
  message: 'test',
  'g-recaptcha-response': '',
  contact: 'contact'
}

here is the response i am getting i want to extract g-recaptcha-response in my backend how can i do that?

I tried to explain as much as i can and also i tried to search on google but i was not able to find something ,Thank you for the help in advance :D


Solution

  • You can use the bracket notation to access a property of an object:

    obj['g-recaptcha-response']
    

    See Property accessors