Skip to content

RequestQuickConfig ​

The request-level configuration of the shortcut methods (get / post / put / patch / del / head / options) and the instance shortcut methods, mirroring the config of axios.get(url, config).

uts
export type RequestQuickConfig = {
	/** Request method; omitted or null uses the instance default (GET) */
	method?: RequestMethod | null
	/** baseURL per-request override */
	baseURL?: string | null
	/** Query parameters: merged with the url's existing query, encoded and joined uniformly by the library */
	params?: UTSJSONObject | null
	/** Request body; a UTSJSONObject on GET/HEAD is automatically merged into the query */
	data?: any | null
	/** Request header; shallow-merged with the instance default header (request-level keys override same-name keys) */
	header?: UTSJSONObject | null
	/** Timeout in ms; omitted or null uses the instance default (60000) */
	timeout?: number | null
	/** Response dataType (json / other), passed through to the native adapter */
	dataType?: string | null
	/** Response data type, passed through natively (ArrayBuffer: app-android 4.51+ / app-ios 4.61+) */
	responseType?: string | null
	/** The native capability parameters below are passed through in full; this library does not normalize them — per-platform support depends on the official docs */
	enableQuic?: boolean | null
	sslVerify?: boolean | null
	withCredentials?: boolean | null
	firstIpv4?: boolean | null
	enableChunked?: boolean | null
	/** Status code check; omitted or null uses the instance default (2xx) */
	validateStatus?: ((statusCode: number) => boolean) | null
	/** Cancel token; omitted or null means not cancelable */
	cancelToken?: CancelToken | null
	/** Request body transform; providing one replaces the built-in behavior (data may be null, same as RequestConfig) */
	transformRequest?: ((data: any | null) => any) | null
	/** Response body transform; providing one replaces the built-in (built-in = pass through as-is; nullable parameter as above) */
	transformResponse?: ((data: any | null) => any) | null
	/** Escape hatch: access the native RequestTask (chunked listening and other advanced scenarios) */
	onTask?: ((task: RequestTask) => void) | null
}

Why there is no url field

url is provided by the first parameter of the shortcut methods and is deliberately omitted from the type, so callers don't have to pass a placeholder just to satisfy the required RequestConfig.url. Apart from url, the fields map one-to-one to RequestConfig with exactly the same semantics.

The method field is not passed through

A shortcut method's method is fixed by its name (post() always sends POST); config.method does not participate in merging — the field is kept only for structural alignment with RequestConfig. Do not rely on it to change the request method.

Fields ​

NameTypeDefaultDescription
methodRequestMethod | null(not passed through)Decided by the shortcut method name; see the warning above
baseURLstring | nullInstance defaultPer-request override of the global baseURL
paramsUTSJSONObject | null—Query parameters, deterministically encoded into the url by the library
dataany | null—Request-level data; shares the same slot as the method's data parameter, which takes precedence (on POST/PUT/PATCH the method parameter overrides this field when merging)
headerUTSJSONObject | nullInstance default headerShallow-merged; request-level keys override same-name keys
timeoutnumber | nullInstance default (60000)Timeout in ms
dataTypestring | nullNative default (json)Passed through natively
responseTypestring | null—Passed through natively
enableQuicboolean | nullNative defaultNative capability parameter, passed through in full
sslVerifyboolean | nullNative defaultSame as above
withCredentialsboolean | nullNative defaultSame as above
firstIpv4boolean | nullNative defaultSame as above
enableChunkedboolean | nullNative defaultSame as above
validateStatus((statusCode: number) => boolean) | nullInstance default (2xx)Overridden as a whole
cancelTokenCancelToken | nullnullPassing one enables cancellation; see createCancelSource()
transformRequest((data: any | null) => any) | nullBuilt-in behaviorProviding one replaces the built-in
transformResponse((data: any | null) => any) | nullBuilt-in behaviorProviding one replaces the built-in
onTask((task: RequestTask) => void) | null—Native RequestTask escape hatch

Companion Methods ​

Examples ​

uts
import { get } from '@/uni_modules/ux-request'

const header: UTSJSONObject = {}
header['Accept-Language'] = 'zh-CN'

get<Array<UTSJSONObject>>('/api/users', {
	params: { 'page': 1 },
	header: header,
	timeout: 10000
}).then((res) => {
	console.log(res.data.length)
})

Released under the MIT License.