我试图在nodejs typescript项目中使用axios,在构建过程中,它引发了错误abortSignal
任何针对此问题的修复,感谢帮助
index.ts
export async function getAccessToken(apiConfig: any) {
const req = {
grant_type: apiConfig.authOptions.body.grant_type,
client_id: apiConfig.authOptions.credentials.clientId,
client_secret: apiConfig.authOptions.credentials.clientSecret,
scope: apiConfig.authOptions.body.scope
};
const headers = {
"Content-Type": "application/x-www-form-urlencoded",
"appName": "Blink"
};
try {
const resp: AxiosResponse = await axios.post('https://test.com//auth/oauth2/token',
req, { headers });
console.log(resp.data);
} catch (err) {
// Handle Error Here
console.error(err);
}
}
错误
node_modules/axios/index.d.ts(93,12): error TS2304: Cannot find name 'AbortSignal'.
Package.json
"axios": "^0.24.0",
1条答案
按热度按时间h7appiyu1#
尝试在axios参数中提供
abortController
信号: