I’m currently implementing 2FA authentication using a phone number, and I’m attempting to obtain the user’s primary phone number from the clerk. This information should be acquired after a successful sign-in with email and password. Is there a method to retrieve this data within the current session, or would it necessitate the creation of an API for this purpose?
const onSignInPress = async () => {
if (!isLoaded) { return; }
setLoading(true);
try {
const completeSignIn = await signIn.create({
identifier: emailAddress,
password,
});
console.log(user);
await completeSignIn.prepareFirstFactor({
phoneNumberId: '',
strategy: 'phone_code',
})
let number = user?.primaryPhoneNumber?.toString() || '';
router.push({ pathname: '/verificationPhone/[phone], params: { phone: number } }); }
catch (err: any)
{ alert(err.errors[0].message); }
finally { setLoading(false); }
};