实现GitHub登录时出现TypeError: Cannot read properties of undefined (reading 'post')
GitHub登录功能axios.post报错排查求助
我在Skillshare平台学习搭建微博客,实现GitHub登录功能时,编写了以下调用axios.post的代码:
const githubAuthResult = await axios.post( `https://github.com/login/oauth/access_token?client_id=${environment.clientId}&client_secret=${environment.clientSecret}&code=${code}`, null, { headers: { Accept: 'application.json' } } );
调用该路由时,第12行触发错误:TypeError: Cannot read properties of undefined (reading 'post')。
我已经确认完成了axios和环境变量的导入:
import axios from 'axios'; import { environment } from '../../environments/environment';
完整路由代码位于项目的apps/api/src/app/routes/Auth.ts文件中,恳请帮忙排查错误原因。
内容的提问来源于stack exchange,提问作者Chris Williamson
相关产品推荐
相关产品推荐

