Skip to main content

get

Gets a value from an interaction object using a dot-notation key path.

Import

You can import the entire package and access the function:


_10
import * as sdk from "@onflow/sdk"
_10
_10
sdk.get(ix, key, fallback)

Or import directly the specific function:


_10
import { get } from "@onflow/sdk"
_10
_10
get(ix, key, fallback)

Usage


_14
import { get, put, initInteraction } from "@onflow/sdk"
_14
_14
const interaction = initInteraction();
_14
_14
// Set a value first
_14
put("user.name", "Alice")(interaction);
_14
_14
// Get the value
_14
const userName = get(interaction, "user.name"); // "Alice"
_14
const userAge = get(interaction, "user.age", 25); // 25 (fallback)
_14
_14
// Get nested values
_14
put("config.network.url", "https://access.mainnet.onflow.org")(interaction);
_14
const networkUrl = get(interaction, "config.network.url");

Parameters

ix

  • Type: Interaction
  • Description: The interaction object

key

  • Type: string
  • Description: The dot-notation key path (e.g., "message.arguments")

fallback (optional)

  • Type: any
  • Description: The fallback value if the key is not found

Returns

any


Rate this page