22 lines
811 B
TypeScript
22 lines
811 B
TypeScript
|
import {unstable_noStore as noStore} from 'next/cache';
|
||
|
import axios, {AxiosResponse} from "axios";
|
||
|
import {DataType, ResponseVO, ResultPage} from "@/app/lib/definitions";
|
||
|
|
||
|
export async function taskTreeResult():Promise<ResponseVO<ResultPage<DataType>>> {
|
||
|
noStore();
|
||
|
try {
|
||
|
// 使用 Axios 发送 POST 请求获取数据
|
||
|
const response: AxiosResponse<ResponseVO<ResultPage<DataType>>> = await axios.post('http://localhost:8090/task/tree', {
|
||
|
pageSize: 10,
|
||
|
pageNumber: 1
|
||
|
});
|
||
|
// 从响应中提取数据并返回
|
||
|
return response.data;
|
||
|
} catch (error) {
|
||
|
// 处理错误
|
||
|
console.error('Error fetching data:', error);
|
||
|
// 返回一个默认值或者抛出错误
|
||
|
throw new Error('Failed to fetch data');
|
||
|
}
|
||
|
}
|