我有一个来自GraphCMS的启动和运行的应用程序接口。
我正在建立一个小的静态网站,希望与盖茨比,我想采取一些数据从GraphCMS与图形am客户端(https://github.com/prismagraphql/graphql-request)
问题是,我在执行以下操作时获得了一个types.js:24 Uncaught (in promise) Error: GraphQL Error (Code: 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))有什么想法吗?
非常感谢
发布于 2018-06-11 03:58:35
您是否允许您查询的字段具有读取权限?或者您正在使用令牌?你真的能发布你从请求中得到的错误响应吗?
https://stackoverflow.com/questions/50730157
复制相似问题