The SDK provides synchronous and asynchronous methods for getting a Member. The recommended approach is to use the synchronous method, member.getSync, and listen to changes with the member.onChange method.
The asynchronous method, member.get, wraps the Search Member endpoint. It fetches the Member's data and refreshes the cached object if changes are detected. The Stytch SDK will invoke this method automatically in the background, so you probably won't need to call this method directly.
The member.getInfo method is similar to member.getSync, but it returns an object containing the member object and a fromCache boolean. If fromCache is true, the Member object is from the cache and a state refresh is in progress.
The member.onChange method takes in a callback that gets called whenever the Member object changes. It returns an unsubscribe method for you to call when you no longer want to listen for such changes.
In React, the @stytch/react library provides the useStytchMember hook that implements these methods for you to easily access the Member and listen for changes.
The asynchronous method, member.get, wraps the Search Member endpoint. It fetches the Member's data and refreshes the cached object if changes are detected. The Stytch SDK will invoke this method automatically in the background, so you probably won't need to call this method directly.