-2

So I'm playing around with creating a Facebook chatbot. In order to talk to Facebook I need to validate I have ownership of the URL I give Facebook in the Webhooks panel.

I have an express route that looks like

app.get('/api/verification', (req, res) => {
  // Send back hub.challenge
});

So in the req object I get back from Facebook it looks like:

{ 'hub.mode': 'subscribe',
   'hub.challenge': '178462834',
   'hub.verify_token': 'my_verify_token' }

In order to get to this I console.log out req.query and get this back. But I can't then go req.query.hub.challenge because I'll get undefined since hub.challenge is the value name.

How do I access the value if it's got a . in it's name?

pourmesomecode
  • 4,108
  • 10
  • 46
  • 87

1 Answers1

3

Use req.query['hub.challenge']

More information on MDN

nilobarp
  • 3,806
  • 2
  • 29
  • 37