0

Hi I am trying to get the gender back from a curl request in node.js. I am following these instructions https://developers.facebook.com/docs/messenger-platform/user-profile

my code is below, but i get an error during the execution.

I call the below using fbUserInfo(recipentId).catch(console.error);

const fbUserInfo = (id) => {
  //const body = JSON.stringify({
  //  recipient: { id },
  //  message: { text },
  //});
  const qs = 'access_token=' + encodeURIComponent(FB_PAGE_TOKEN1);
  return fetch('https://graph.facebook.com/v2.6/' + id + '?fields=first_name,last_name,profile_pic,locale,timezone,gender&' + qs, {
    method: 'POST',
    headers: {'Content-Type': 'application/json'},
    //body,
  })
  .then(rsp => rsp.json())
  .then(json => {
    if (json.error && json.error.message) {
      throw new Error(json.error.message);
    }
    return json;
  });
  console.log('=== ' + json); // I was hoping this would output the returned json
}; // const
Ethan Richardson
  • 461
  • 2
  • 10
  • 28

0 Answers0