Skip to content

uni-app adapter

axiosUtil.request() automatically uses the uni-app adapter when the global uni object exists. Fast.NET-generated mobile uploads keep the established method contract:

ts
const fileId = await axiosUtil.request<string>({
	url: "/files/avatar",
	method: "upload",
	requestType: "upload",
	filePath,
	name: "file",
	cancelDuplicateRequest: false,
});

Install the adapter explicitly when creating a raw Axios instance:

ts
import axios from "axios";
import { createUniAppAxiosAdapter } from "@fast-china/axios";

const http = axios.create({
	adapter: createUniAppAxiosAdapter(),
	baseURL: "https://api.example.com",
});

const response = await http.upload(
	"/files/avatar",
	{},
	{
		filePath,
		name: "file",
	}
);

See the uni-app adapter documentation for upload, download, cancellation, progress, and platform behavior.