试图在GraphCMS api上连接时出现Gatsby Graphql问题
我有一个从GraphCM启动并运行的api 我正在建立一个小的静态网站,希望与盖茨比和我想采取一些数据从GraphCMS与Graphql客户端() 问题是,在执行以下操作时,我得到了一个试图在GraphCMS api上连接时出现Gatsby Graphql问题,graphql,graphql-js,gatsby,Graphql,Graphql Js,Gatsby,我有一个从GraphCM启动并运行的api 我正在建立一个小的静态网站,希望与盖茨比和我想采取一些数据从GraphCMS与Graphql客户端() 问题是,在执行以下操作时,我得到了一个types.js:24未捕获(承诺中)错误:GraphQL错误(代码:200): 我的index.js import React from 'react' import PropTypes from 'prop-types' import Helmet from 'react-helmet' import { G
types.js:24未捕获(承诺中)错误:GraphQL错误(代码:200)
:
我的index.js
import React from 'react'
import PropTypes from 'prop-types'
import Helmet from 'react-helmet'
import { GraphQLClient } from 'graphql-request'
import Header from '../components/header'
import './index.css'
export default () =>
<div style={{ color: `tomato` }}>
<h1>Hello Gatsby!</h1>
<p>What a world.</p>
</div>
const client = new GraphQLClient('my-endpoint', {
headers: {
Authorization: 'mytokenfromGraphCms',
},
})
const query = `{
allCurrentEvents{
tip
awayteam
hometeam
date
}
allPasteventses{
tip
}
}`
client.request(query).then(data => console.log(data))
从“React”导入React
从“道具类型”导入道具类型
从“反应头盔”导入头盔
从“graphql请求”导入{GraphQLClient}
从“../components/Header”导入标题
导入“./index.css”
导出默认值()=>
你好,盖茨比!
多么美好的世界啊
const client=new GraphQLClient('my-endpoint'{
标题:{
授权:“mytokenfromGraphCms”,
},
})
常量查询=`{
allCurrentEvents{
提示
阿瓦泰姆
主队
日期
}
阿尔帕斯特文茨酒店{
提示
}
}`
client.request(query).then(data=>console.log(data))
有什么想法吗
非常感谢您是否允许对正在查询的字段进行读取权限?或者你在使用代币?您是否可以发布从请求中得到的错误响应