Skip to content

Quick start

Create the global FastAxios container once during application startup, then send requests through axiosUtil.request():

ts
import { axiosUtil, createFastAxios } from "@fast-china/axios";

const fastAxios = createFastAxios({
	baseUrl: "https://api.example.com",
	timeout: 30_000,
	headers: {
		Authorization: "Bearer <token>",
	},
	requestCipher: false,
});

interface User {
	id: number;
	name: string;
}

const user = await axiosUtil.request<User>({
	url: "/users/1",
	method: "get",
	requestType: "query",
});

By default, axiosUtil.request() reads code, success, message, and data from the Fast.NET RESTful response and resolves with data. Disable simpleDataFormat or restfulResult on an individual request when the original structure is required.