let companyInfo: PublicCompanyAPIResponseType;
companyInfo = await get<PublicCompanyAPIResponseType>({
url: getcompanyDataURL,}).catch(res => {
responseStatus = res.status;
});
当我将companyInfo变量分配给该函数时
export async function get<T>({ url,headers }: ApiConnectSet): Promise<T> {
return new Promise((resolve,reject) => {
fetch(url,{
method: 'GET',credentials: 'same-origin',headers: headers,})
.then(async res => {
if (res.ok) {
return resolve((await res.json()) as Promise<T>);
} else if (res.status === 401) {
const redirectPath = window.location.pathname;
window.location.href =
'/login?redirectPath=' + redirectPath;
} else {
reject(res);
}
})
.catch(error => {
reject(error);
});
});
}
我的get函数如何只能返回PublicCompanyAPIResponseType
?