The OwnID JS SDK allows you to perform various operations on the logged-in user’s account directly within their session. Below are examples of how to retrieve and update a user’s profile using the SDK.

Retrieve an Account’s Profile

You can retrieve the currently logged-in user’s profile with the following code:

ownid.profile.get()
.then(profileData => {
  console.log("Profile retrieved successfully:", profileData);
})
.catch(error => {
  console.error("Error retrieving profile:", error);
});

This operation fetches the profile data for the logged-in user and allows you to interact with their account information directly within the frontend.

Update an Existing Account Profile

To update the profile of the logged-in user, use the following example:

ownid.profile.update({
  firstName: "Sassi",
  lastName: "Keshet"
})
.then(updatedProfile => {
  console.log("Profile updated successfully:", updatedProfile);
})
.catch(error => {
  console.error("Error updating profile:", error);
});

This code updates the user’s profile with the provided information and reflects the changes in their active session.