Class

ApiClient

ApiClient()

Client which access the admin API. Use it to fetch data from auto generated AdminBro API.

In the backend it uses axios client library.

Usage:

import { ApiClient } from 'admin-bro'

const api = new ApiClient()
api.getRecords({ resourceId: 'Comments' }).then(results => {...})

Methods

# async bulkAction(options) → {Promise.<BulkActionResponse>}

Invokes given bulk Action on the backend.

Parameters:
Name Type Description
options BulkActionAPIParams

View Source admin-bro/src/frontend/utils/api-client.ts, line 108

response from an Action

Promise.<BulkActionResponse>

# async getDashboard(options) → {Promise.<any>}

Invokes dashboard handler.

Parameters:
Name Type Description
options AxiosRequestConfig

View Source admin-bro/src/frontend/utils/api-client.ts, line 129

response from the handler function defined in AdminBroOptions#dashboard

Promise.<any>

# async getPage(options) → {Promise.<any>}

Invokes handler function of given page and returns its response.

Parameters:
Name Type Description
options GetPageAPIParams

View Source admin-bro/src/frontend/utils/api-client.ts, line 141

response from the handler of given page defined in AdminBroOptions#pages

Promise.<any>

# async recordAction(options) → {Promise.<RecordActionResponse>}

Invokes given record Action on the backend.

Parameters:
Name Type Description
options RecordActionAPIParams

View Source admin-bro/src/frontend/utils/api-client.ts, line 91

response from an Action

Promise.<RecordActionResponse>

# async resourceAction(options) → {Promise.<ActionResponse>}

Invokes given resource Action on the backend.

Parameters:
Name Type Description
options ResourceActionAPIParams

View Source admin-bro/src/frontend/utils/api-client.ts, line 74

response from an Action

Promise.<ActionResponse>

# async searchRecords(options) → {Promise.<SearchResponse>}

Search by query string for records in a given resource.

Parameters:
Name Type Description
options Object
resourceId String

id of a ResourceJSON

query String

query string

View Source admin-bro/src/frontend/utils/api-client.ts, line 62

Promise.<SearchResponse>

Type Definitions

object

# BulkActionAPIParams

Properties:
Name Type Description
... any

any property supported by AxiosRequestConfig

recordIds Array.<string>

id of a record taken from RecordJSON

resourceId string

id of a resource taken from ResourceJSON

actionName string

action name taken from ActionJSON

See:

View Source admin-bro/src/frontend/utils/api-client.ts, line 180

object

# GetPageAPIParams

Properties:
Name Type Description
... any

any property supported by AxiosRequestConfig

pageName string

Unique page name

View Source admin-bro/src/frontend/utils/api-client.ts, line 192

object

# RecordActionAPIParams

Properties:
Name Type Description
... any

any property supported by AxiosRequestConfig

recordId string

id of a record taken from RecordJSON

resourceId string

id of a resource taken from ResourceJSON

actionName string

action name taken from ActionJSON

View Source admin-bro/src/frontend/utils/api-client.ts, line 169

object

# ResourceActionAPIParams

Properties:
Name Type Description
... any

any property supported by AxiosRequestConfig

resourceId string

id of a resource taken from ResourceJSON

actionName string

action name taken from ActionJSON

View Source admin-bro/src/frontend/utils/api-client.ts, line 159