无法从“tryghost”获取帖子并出现 Axios 错误

问题描述 投票:0回答:1

我正在使用 Next.js 和 Ghost API 构建一个无头博客。

按照 Youtube 上的教程,我能够一步一步地进行操作,但我卡在从“tryghost”接收数据上。

使用 Ghost api_url、api_key 和 api_version,我应该能够获取帖子,但我收到以下错误。

AxiosError:没有合适的适配器来分派请求,因为:

  • 环境不支持适配器xhr
  • 适配器 http 在构建中不可用 在 Object.getAdapter (webpack-internal:///(rsc)/./node_modules/@tryghost/content-api/es/content-api.js:2027:19) 在 Axios.dispatchRequest (webpack-internal:///(rsc)/./node_modules/@tryghost/content-api/es/content-api.js:2065:30) 在 Axios.request (webpack-internal:///(rsc)/./node_modules/@tryghost/content-api/es/content-api.js:2363:39) 在 Axios。 [作为获取] (webpack-internal:///(rsc)/./node_modules/@tryghost/content-api/es/content-api.js:2388:21) 在 Function.wrap [as get] (webpack-internal:///(rsc)/./node_modules/@tryghost/content-api/es/content-api.js:7:19) 默认MakeRequest (webpack-internal:///(rsc)/./node_modules/@tryghost/content-api/es/content-api.js:2770:27) 在 makeApiRequest (webpack-internal:///(rsc)/./node_modules/@tryghost/content-api/es/content-api.js:2915:16) 在 Object.browse (webpack-internal:///(rsc)/./node_modules/@tryghost/content-api/es/content-api.js:2868:20) 在 getPosts (webpack-internal:///(rsc)/./app/ghost/post.js:13:28) 在家 (webpack-internal:///(rsc)/./app/page.jsx:11:78) 在 listOnTimeout (节点:内部/计时器:569:17) 在 process.processTimers (节点:内部/计时器:512:7){ 代码:'ERR_NOT_SUPPORT' } { 帖子:未定义 }

我尝试安装 axios 依赖项,但不起作用

next.js ghost-blog
1个回答
0
投票

尝试在 useEffect 中调用此 Content API,对我有用

© www.soinside.com 2019 - 2024. All rights reserved.