I am defined the MenuItem
like this to parse the server side rest api response:
type MenuItem = {
id: number;
name: string;
path: string;
tree_id_path: string;
children: MenuItem[];
};
the server side return more than 4 fields, but I only want the MenuItem
to take 4 fields. what should I do to make it work like this? Now I am using as to cast the reponse to MenuItem
list.
export async function roleMenuTree(options?: { [key: string]: any }) {
let response = await request<API.ApiResponse>('/manage/permission/role/v1/role/menu', {
method: 'POST',
body: JSON.stringify({}),
...(options || {}),
});
let dataList = response.result as API.MenuItem[];
return dataList;
}