# Function getSafe

- getSafe<T>(fn: () => T, defaultVal?: T): T

  Avoid "can't access property of undefined" errors in a more readable way.

  #### Type Parameters

  - T

  #### Parameters

  - fn: () => T

    Function that wraps a nested property access

  - `Optional` defaultVal: T

    Optional - the value to return if property access failed

  #### Returns T

  - Defined in packages/shared/src/utils/getSafe.ts:7