/**
 * @desc 查询类型
 */
import { defaultSuccess, defaultError, http } from '@/plugins/axios'
import type { AxiosResponse } from 'axios'
export interface Params {
	/** 搜索关键词 */
	key?: string
}

export default async function (
	params: Params,
	success: (data: Array<material.Type>) => void = defaultSuccess,
	fail: (error: { code: string; error?: string }) => void = defaultError,
): Promise<void> {
	return http({
		method: 'get',
		url: `/areas`,

		params,
	})
		.then((data: AxiosResponse<Array<material.Type>, unknown>) => {
			success(data.data)
		})
		.catch((error: { code: string; error?: string }) => fail(error))
}
