You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

实现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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 00:30:54