logologo
Start
Handleiding
Ontwikkeling
Plugins
API
English
简体中文
日本語
한국어
Deutsch
Français
Español
Português
Русский
Italiano
Türkçe
Українська
Tiếng Việt
Bahasa Indonesia
ไทย
Polski
Nederlands
Čeština
العربية
עברית
हिन्दी
Svenska
Start
Handleiding
Ontwikkeling
Plugins
API
logologo
API-overzicht

@nocobase/auth

AuthManager
Auth
BaseAuth

@nocobase/cache

CacheManager
Cache

@nocobase/cli

NocoBase CLI
Globale Omgevingsvariabelen

@nocobase/client

Applicatie
Plugin

@nocobase/database

Collectie
Veld

interfaces

BaseInterface
Filteroperatoren

RelationRepository

BelongsToManyRepository
belongs-to-repository
HasManyRepository
HasOneRepository
Repository

shared

create-options
destroy-options
find-one
find-options
transaction
update-options

@nocobase/data-source-manager

DataSourceManager
DataSource (abstract)
ICollectionManager
ICollection
IField
IModel
IRepository

@nocobase/flow-engine

Gegevensbronbeheerder
FlowContext
FlowEngine
FlowModel
Workflowbron

@nocobase/logger

Logger

@nocobase/server

AppCommand
Applicatie
AuditManager
Context
Migratie
Plugin

@nocobase/sdk

Auth
Storage
Previous PagePlugin
Next PageAuth
TIP

Dit document is vertaald door AI. Voor onnauwkeurigheden, raadpleeg de Engelse versie

#APIClient

#Overzicht

APIClient is een wrapper gebaseerd op axios. U gebruikt deze om NocoBase collectie acties aan te vragen via HTTP aan de clientzijde.

#Basisgebruik

class PluginSampleAPIClient extends Plugin {
  async load() {
    const res = await this.app.apiClient.request({
      // ...
    });
  }
}

#Instantie-eigenschappen

#axios

De axios-instantie, waarmee u toegang krijgt tot de axios API, bijvoorbeeld apiClient.axios.interceptors.

#auth

De client-side authenticatieklasse, zie Auth.

#storage

De client-side opslagklasse, zie Storage.

#Klassemethoden

#constructor()

De constructor, die een APIClient-instantie aanmaakt.

#Signatuur

  • constructor(instance?: APIClientOptions)

#Type

interface ExtendedOptions {
  authClass?: any;
  storageClass?: any;
}

export type APIClientOptions =
  | AxiosInstance
  | (AxiosRequestConfig & ExtendedOptions);

#request()

Start een HTTP-verzoek.

#Signatuur

  • request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D> | ResourceActionOptions): Promise<R>

#Type

type ResourceActionOptions<P = any> = {
  resource?: string;
  resourceOf?: any;
  action?: string;
  params?: P;
};

#Details

#AxiosRequestConfig

Algemene axios-verzoekparameters. Zie Request Config.

const res = await apiClient.request({ url: '' });
#ResourceActionOptions

NocoBase collectie actie-verzoekparameters.

const res = await apiClient.request({
  resource: 'users',
  action: 'list',
  params: {
    pageSize: 10,
  },
});
EigenschapTypeBeschrijving
resourcestring1. Collectienaam, bijv. a
2. Naam van het gekoppelde object van de collectie, bijv. a.b
resourceOfanyWanneer resource de naam is van het gekoppelde object van de collectie, is dit de primaire sleutelwaarde van de collectie. Bijvoorbeeld, voor a.b vertegenwoordigt het de primaire sleutelwaarde van a.
actionstringActienaam
paramsanyVerzoekparameterobject, voornamelijk URL-parameters. De verzoekbody wordt in params.values geplaatst.
params.valuesanyVerzoekbody-object

#resource()

Haalt het NocoBase collectie actiemethode-object op.

const resource = apiClient.resource('users');

await resource.create({
  values: {
    username: 'admin',
  },
});

const res = await resource.list({
  page: 2,
  pageSize: 20,
});

#Signatuur

  • resource(name: string, of?: any, headers?: AxiosRequestHeaders): IResource

#Type

export interface ActionParams {
  filterByTk?: any;
  [key: string]: any;
}

type ResourceAction = (params?: ActionParams) => Promise<any>;

export type IResource = {
  [key: string]: ResourceAction;
};

#Details

ParameterTypeBeschrijving
namestring1. Collectienaam, bijv. a
2. Naam van het gekoppelde object van de collectie, bijv. a.b
ofanyWanneer name de naam is van het gekoppelde object van de collectie, is dit de primaire sleutelwaarde van de collectie. Bijvoorbeeld, voor a.b vertegenwoordigt het de primaire sleutelwaarde van a.
headersAxiosRequestHeadersHTTP-headers die moeten worden meegestuurd bij volgende collectie actie-verzoeken.