1.13.1 • Published 3 months ago

@squiz/xaccel-data-fetcher v1.13.1

Weekly downloads
-
License
ISC
Repository
-
Last release
3 months ago

Data Fetcher

Description

A utility for fetching an array of child assets from a root node using the Matrix Content API

See example.ts for working example implementation

import { MatrixApiAdapter, DataFetcher } from @squiz/xaccel-data-fetcher;

const matrixAdapter = new MatrixApiAdapter(rootNodeId, assetType, resultLimit, sortByOptions.name, sortOrderOptions.asc, customMap);

(async () => {
    const getData = await DataFetcher(matrixAdapter, apiEndpoint, apiKey);
    console.log(getData);
})();

MatrixApiAdapter

Class constructor that returns and transforms Matrix data

Usage

import { MatrixApiAdapter } from @squiz/xaccel-data-fetcher;

const matrixAdapter = new MatrixApiAdapter(rootNodeId, assetType, resultLimit, sortByOptions.name, sortOrderOptions.asc, customMap);

required arguments

optional arguments

  • resultLimit { Number = 20 }
  • sortBy { String of the following value }
    • id
    • type
    • version
    • name
    • shortName
    • statusId
    • createdDate
    • updatedDate
    • publishedDate
    • statusChangedDate
  • sortOrder { String of the following value }
    • asc
    • desc
  • customMap { Callback function to transform the raw data returned by the API }

DataFetcher

A function that takes an adapter, API endpoint URL and API key

Usage

import { DataFetcher } from @squiz/xaccel-data-fetcher;

(async () => {
    const getData = await DataFetcher(matrixAdapter, apiEndpoint, apiKey);
})();

required arguments

  • matrixAdapter { Matrix adapter }
  • apiEndPoint { String }

Local Development

npm run start will run the example.ts file on Node and console log the returned data

For simple local development set up a .env file with the following variables and/or edit the example.ts file to your liking

CONTENT_API=" "

CONTENT_API_KEY=" "

1.13.1

3 months ago

1.12.1

4 months ago

1.13.0-beta.1

4 months ago

1.9.1-alpha.0

4 months ago

1.12.1-alpha.0

4 months ago

1.9.1-beta.0

4 months ago

1.9.0

4 months ago

1.11.0-alpha.25

4 months ago

1.9.0-beta.37

4 months ago

1.9.0-beta.33

4 months ago

1.11.0-alpha.19

4 months ago

1.11.0-alpha.17

4 months ago

1.11.0-alpha.8

5 months ago

1.11.0-alpha.6

5 months ago

1.9.0-beta.27

5 months ago

1.11.0-alpha.5

5 months ago

1.9.0-beta.25

6 months ago

1.9.0-beta.24

6 months ago

1.10.0-alpha.17

6 months ago

1.10.0-alpha.16

6 months ago

1.10.0-alpha.15

6 months ago

1.10.0-alpha.14

6 months ago

1.10.0-alpha.12

6 months ago