UNPKG

@mi-gpt/miot

Version:

MIoT 非官方 Node.js 客户端

26 lines (23 loc) 911 B
import { AxiosRequestConfig } from 'axios'; import { MiAccount } from '../mi/typing.js'; interface HttpError { isError: true; error: any; code: string; message: string; } type RequestConfig = AxiosRequestConfig<any> & { account?: MiAccount; setAccount?: (newAccount: any) => void; rawResponse?: boolean; cookies?: Record<string, string | number | boolean | undefined>; }; declare class HTTPClient { timeout: number; get<T = any>(url: string, _query?: Record<string, string | number | boolean | undefined> | RequestConfig, _config?: RequestConfig): Promise<T | HttpError>; post<T = any>(url: string, data?: any, config?: RequestConfig): Promise<T | HttpError>; static buildURL: (url: string, query?: Record<string, any>) => string; static buildConfig: (config?: RequestConfig) => RequestConfig | undefined; } declare const Http: HTTPClient; export { Http };