【问题标题】:Graphql query data from github api in Gatsby来自 Gatsby 中 github api 的 Graphql 查询数据
【发布时间】:2021-01-15 10:53:17
【问题描述】:

我正在使用 Gatsby 的 Gatsby-theme-portfolio,仅当我尝试构建 gatsby 站点时,我在 graphql 查询中收到错误。

There was an error in your GraphQL query:

Response not successful: Received status code 401

   1 | query cUsersLeviDesktopGatsbyPortfolionodeModulesgatsbyThemePortfoliosrccomponentslandingProjectsindexJsx3489004344 {
   2 |   github {
>  3 |     viewer {
     |     ^
   4 |       repositories(first: 8, orderBy: {field: STARGAZERS, direction: DESC}) {
   5 |         edges {
   6 |           node {
   7 |             id
   8 |             name
   9 |             url
  10 |             description
  11 |             stargazers {
  12 |               totalCount
  13 |             }

【问题讨论】:

    标签: github graphql gatsby github-api


    【解决方案1】:

    您可以使用 Gatsby 插件从 Github 的 GraphQl API 中获取资源。 https://www.gatsbyjs.com/plugins/gatsby-source-github-api/。您需要在 Github 上生成令牌并将其传递到插件配置中。

    【讨论】:

      猜你喜欢
      • 2019-10-25
      • 2020-03-23
      • 2019-11-22
      • 2023-03-08
      • 1970-01-01
      • 1970-01-01
      • 2021-05-04
      • 2019-04-02
      • 1970-01-01
      相关资源
      最近更新 更多