Skip to content

    itemsOf

    Extract records from one JSON list response. Use this when you already have a page and want to process its rows.

    Signature

    itemsOf(response: ApiResponse<unknown>): unknown[]

    Parameters

    response
    A JSON list response with a body object.

    Return value

    The data array, or the first array under data.items, data.rows or data.findings in that order. A JSON object without one of these arrays returns an empty array.

    Errors

    • A null body raises TypeError. Pass a list response with a JSON body.

    TypeScript example

    import { itemsOf } from "@aeoapi/aeo-sdk";
    import { AeoClient } from "@aeoapi/aeo-sdk";
    
    const apiKey = process.env.AEO_API_KEY;
    if (!apiKey) throw new Error("Set AEO_API_KEY on your server.");
    const client = new AeoClient(apiKey, { baseUrl: "https://api.aeoapi.dev" });
    
    const page = await client.v2GetBrands({ limit: 10 });
    console.log(itemsOf(page));

    See TypeScript client setup for authentication, timeouts and retry settings.