For my JavaScript function, I am taking the input "user_id" and expecting it to provide me with the profile photo data. Everything works fine when a logged in user's profile picture is being displayed. However, when I pass a logged out user_id, an error occurs stating "TypeError: response.picture is undefined". This is my first attempt at using the Facebook API to retrieve user information based solely on user_id input. Below is the code snippet for reference where "a" represents the input.
// Function to fetch profile picture with just username input
function getInfopeople(a) {
// Constructing the user_id link for profile picture
var user_id = "/"+a + "/picture";
console.log(user_id);
// Calling FB.api to get profile picture based on user_id
FB.api('/http://graph.facebook.com/user_id,','GET', {fields:'picture.width(150).height(150)'}, function(response) {
document.getElementById('user_status').innerHTML = "<img src='" + response.picture.data.url + "'>";
});
}