logologo
スタート
マニュアル
開発
プラグイン
API
ホーム
English
简体中文
日本語
한국어
Español
Português
Deutsch
Français
Русский
スタート
マニュアル
開発
プラグイン
API
ホーム
logologo
API概要

@nocobase/auth

AuthManager
Auth
BaseAuth

@nocobase/cache

CacheManager
キャッシュ

@nocobase/cli

NocoBase CLI
グローバル環境変数

@nocobase/client

アプリケーション
プラグイン

@nocobase/database

コレクション
フィールド

interfaces

BaseInterface
フィルター演算子

RelationRepository

BelongsToManyRepository
belongs-to-repository
HasManyRepository
HasOneRepository
リポジトリ

shared

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

@nocobase/data-source-manager

DataSourceManager
DataSource (抽象)
ICollectionManager
ICollection
IField
IModel
IRepository

@nocobase/flow-engine

データソースマネージャー
フローコンテキスト
FlowEngine
フローモデル
フローリソース

@nocobase/logger

ロガー

@nocobase/server

AppCommand
アプリケーション
AuditManager
コンテキスト
マイグレーション
プラグイン

@nocobase/sdk

Auth
ストレージ
Previous Pageプラグイン
Next PageAuth
TIP

このドキュメントはAIによって翻訳されました。不正確な情報については、英語版をご参照ください

#APIClient

#概要

APIClient は、axios をベースにラップされており、クライアント側でHTTP経由でNocoBaseのリソース操作をリクエストするために使用されます。

#基本的な使い方

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

#インスタンスプロパティ

#axios

axios インスタンスです。apiClient.axios.interceptors のように、axios API にアクセスできます。

#auth

クライアント認証クラスです。Auth を参照してください。

#storage

クライアントストレージクラスです。Storage を参照してください。

#クラスメソッド

#constructor()

コンストラクタです。APIClient インスタンスを作成します。

#シグネチャ

  • constructor(instance?: APIClientOptions)

#型

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

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

#request()

HTTP リクエストを送信します。

#シグネチャ

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

#型

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

#詳細

#AxiosRequestConfig

一般的な axios のリクエストパラメータです。Request Config を参照してください。

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

NocoBase のリソース操作リクエストパラメータです。

const res = await apiClient.request({
  resource: 'users',
  action: 'list',
  params: {
    pageSize: 10,
  },
});
プロパティ型説明
resourcestring1. リソース名 (例: a)
2. リソースの関連オブジェクト名 (例: a.b)
resourceOfanyresource がリソースの関連オブジェクト名の場合、そのリソースの主キー値です。例えば a.b の場合、a の主キー値を表します。
actionstringアクション名
paramsanyリクエストパラメータオブジェクトです。主にURLパラメータで、リクエストボディは params.values に格納されます。
params.valuesanyリクエストボディオブジェクト

#resource()

NocoBase のリソース操作メソッドオブジェクトを取得します。

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

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

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

#シグネチャ

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

#型

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

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

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

#詳細

パラメータ名型説明
namestring1. リソース名 (例: a)
2. リソースの関連オブジェクト名 (例: a.b)
ofanyname がリソースの関連オブジェクト名の場合、そのリソースの主キー値です。例えば a.b の場合、a の主キー値を表します。
headersAxiosRequestHeaders後続のリソース操作リクエストを送信する際に付加するHTTPリクエストヘッダーです。