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:
_10import * as sdk from "@onflow/sdk"_10_10sdk.get(ix, key, fallback)
Or import directly the specific function:
_10import { get } from "@onflow/sdk"_10_10get(ix, key, fallback)
Usage
_14import { get, put, initInteraction } from "@onflow/sdk"_14_14const interaction = initInteraction();_14_14// Set a value first_14put("user.name", "Alice")(interaction);_14_14// Get the value_14const userName = get(interaction, "user.name"); // "Alice"_14const userAge = get(interaction, "user.age", 25); // 25 (fallback)_14_14// Get nested values_14put("config.network.url", "https://access.mainnet.onflow.org")(interaction);_14const 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