【问题标题】:Why does the GraphQl tutorial (Apollo Odyssey) indicate “Error! Unexpected token < in JSON at position 0”?为什么 GraphQl 教程(Apollo Odyssey)显示“错误! JSON中位置0处的意外令牌<?
【发布时间】:2022-01-26 06:14:02
【问题描述】:

那里! 现在,我正在尝试 GraphQl 教程 (Apollo Odyssey) 并且有一个问题。

the GraphQl tutorial (Apollo Odyssey) 视频的 1:43,屏幕显示 json 响应。

enter image description here

但是,我的屏幕显示以下消息,“错误!上面位置 0 处的 JSON 中的意外标记 ,而不是 json 响应。

我在client/src/pages/tracks.js (GitHub)调试的时候也可以看到“undefined”的字符串。

为什么我的本地主机中的 GraphQl 教程 (Apollo Odyssey) 显示“错误!意外的令牌 document of ODYSSEY - LIFT-OFF I: BASICS 进行编程。

我想让你告诉我如何解决这个错误。

另外,我已经在 Apollo GraphQL 社区发布了same question,但我还没有得到任何答案或提示。

谢谢。

【问题讨论】:

  • 真的需要看这里的代码。
  • 请提供足够的代码,以便其他人更好地理解或重现问题。
  • 嗨,马克。感谢您的评论。当我下次问我不知道的事情时,我会在问题中留下评论。实际上,我已经在下面解决了这个问题。 community.apollographql.com/t/…

标签: graphql apollo apollo-client apollo-server


【解决方案1】:

在src/index.js,我编程like this。

const client = new ApolloClient({
  uri: 'http://localhost:3000/',
  cache: new InMemoryCache()
});

通过将http://localhost:3000/ 替换为http://localhost:4000/,我修复了错误。 另外,我注意到您需要同时调用两个本地主机。

如果你想知道细节,你可以确保下面。

https://community.apollographql.com/t/why-does-the-catstronaut-indicate-error-unexpected-token-in-json-at-position-0/2320/4?u=echizenyayota

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-23
    • 2020-11-20
    • 2022-07-11
    • 2020-05-08
    • 1970-01-01
    • 1970-01-01
    • 2019-04-12
    • 1970-01-01
    相关资源
    最近更新 更多