Quick start
If you already have an API, use the code below. To try a real request first, build the minimal pagination example, which walks through creating a .NET API, configuring the Vite proxy, and setting up FastAxios.
Create the global FastAxios container once during application startup, then send requests through axiosUtil.request():
This example requires your API address. Install the dependencies and initialize the container once in your application entry. The example disables request encryption. Add authentication and handlers as required.
import { axiosUtil, createFastAxios } from "@fast-china/axios";
createFastAxios({
baseUrl: "https://api.example.com",
requestCipher: false,
});
interface User {
id: number;
name: string;
}
const user = await axiosUtil.request<User>({
url: "/users/1",
method: "get",
requestType: "query",
});The default export also provides the FastAxios namespace. See package entries for public imports.
Three JSON response shapes
If Fast.NET returns the following response, user above is { id: 1, name: "Alice" }.
{ "code": 200, "success": true, "message": "", "data": { "id": 1, "name": "Alice" } }| Server response | Per-request option | Return value |
|---|---|---|
| Fast.NET JSON envelope | Defaults | The user object inside data, after checking code and success |
| Fast.NET JSON envelope | simpleDataFormat: false | The full Fast response body, still checking code and success |
Plain JSON { "id": 1, "name": "Alice" } | restfulResult: false | The original JSON body, bypassing Fast business validation and unwrapping |
The full Fast response body is { code, success, message, data }. See request options for file downloads and non-JSON responses.
See remote pagination for wiring a request to FaTable.
