@faable/auth-js - v2.1.0
    Preparing search index...

    Function unwrap

    • Converts a { data, error } result from any FaableAuthClient method into throw-style control flow: returns data on success, throws the AuthError on failure.

      Every async method on the client follows the never-throw contract — expected failures resolve in error rather than rejecting. That is the right default for most UIs, but when you'd rather let an error propagate (a server handler, a try/catch, a wrapper that normalizes everything to throws), unwrap saves you from hand-writing if (error) throw error at every call site.

      Type Parameters

      • Data

      Parameters

      • result: { data: Data; error: AuthError | null }

        Any { data, error } result returned by the client.

      Returns Data

      The data payload when error is null.

      import { unwrap } from '@faable/auth-js'

      // throws AuthError on a wrong OTP instead of returning { error }
      const { session } = unwrap(await auth.signInWithOtp({ username, otp }))

      The error from the result when it is non-null.