Getting an undefined error for the expo Facebook object even though the console log clearly shows otherwise.
import * as Facebook from 'expo-facebook';
export const fbLogIn = async () => {
console.log("Facebook", Facebook.initializeAsync);
// FB ƒ initializeAsync(_x4, _x5) {return _initializeAsync.apply(this, arguments);}
try {
await Facebook.initializeAsync({
appId: "****************",
appName: "My App Name",
}); // Triggers catch here
// Never gets to this line
const { type, token } = await Facebook.logInWithReadPermissionsAsync({
permissions: ['public_profile'],
});
if (type === 'success') {
const response = await fetch(`https://graph.facebook.com/me?access_token=${token}`);
const user = await response.json();authUser.id });
return Promise.resolve({ user });
} else {
throw new Error("Error logging in with Facebook")
}
} catch (err) {
// TypeError: Cannot read properties of undefined (reading 'initializeAsync')
return Promise.reject(err);
}
};