I keep getting TypeError: Cannot read property 'first_name' of undefined
when trying to execute this code (all variables, including modules are defined in other parts of the code):
if (messageText) {
var senderID_first_name = f_User.UserQ(senderID);
sendTextMessage(senderID, String(senderID_first_name));
}
f_User = {
UserQ: function(id) {
var parse_body;
request.get('https://graph.facebook.com/v2.6/'+id+'?fields=first_name,last_name,profile_pic,locale,timezone,gender&access_token='+PAGE_ACCESS_TOKEN, function(error, response, body) {
if (!error && response.statusCode == 200) {
parse_body = body;
}
});
return parse_body.first_name;
}
}