logologo
시작
가이드
개발
플러그인
API
English
简体中文
日本語
한국어
Deutsch
Français
Español
Português
Русский
Italiano
Türkçe
Українська
Tiếng Việt
Bahasa Indonesia
ไทย
Polski
Nederlands
Čeština
العربية
עברית
हिन्दी
Svenska
시작
가이드
개발
플러그인
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
FlowModel
플로우 리소스

@nocobase/logger

로거

@nocobase/server

AppCommand
애플리케이션
AuditManager
컨텍스트
마이그레이션
플러그인

@nocobase/sdk

Auth
Storage
Previous Page플러그인
Next PageAuth
TIP

이 문서는 AI로 번역되었습니다. 부정확한 내용이 있을 경우 영어 버전을 참조하세요

#APIClient

#개요

APIClient는 axios를 기반으로 하는 래퍼(wrapper)입니다. 클라이언트 측에서 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가 리소스의 연결된 객체 이름일 때, 해당 리소스의 기본 키(primary key) 값입니다. 예를 들어, a.b일 경우 a의 기본 키 값을 나타냅니다.
actionstring작업 이름
paramsany요청 파라미터 객체로, 주로 URL 파라미터에 사용됩니다. 요청 본문(request body)은 params.values에 포함됩니다.
params.valuesany요청 본문(request body) 객체

#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이 리소스의 연결된 객체 이름일 때, 해당 리소스의 기본 키(primary key) 값입니다. 예를 들어, a.b일 경우 a의 기본 키 값을 나타냅니다.
headersAxiosRequestHeaders이후 리소스 작업 요청 시 포함될 HTTP 헤더입니다.