react-apollo Error: [Network error]: ServerParseError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
react-apollo Error: [Network error]: ServerParseError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
我想通过apollo向服务器发送请求并获取查询:
import React, { Component } from 'react';
import { gql } from 'apollo-boost';
import { graphql } from 'react-apollo';
const getBooksQuery = gql`
{
books{
name
id
}
}
`
class BookList extends Component {
render() {
console.log(this.props);
return (
<div>
<ul id="book-list">
<li>Book Name</li>
</ul>
</div>
);
}
}
export default graphql(getBooksQuery)(BookList);
但是我收到以下错误。
[Network error]: ServerParseError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
我已经用 nodejs 和 graphql 配置了后端服务器。
但我可以轻松地在我的浏览器中打开“http://localhost:4000/graphql/”发送下面的查询
{
books{
name
id
}
}
并从数据库中获取数据。有谁知道问题出在哪里?
我已经弄清楚了问题,我指出我的客户错了 URL。
我想通过apollo向服务器发送请求并获取查询:
import React, { Component } from 'react';
import { gql } from 'apollo-boost';
import { graphql } from 'react-apollo';
const getBooksQuery = gql`
{
books{
name
id
}
}
`
class BookList extends Component {
render() {
console.log(this.props);
return (
<div>
<ul id="book-list">
<li>Book Name</li>
</ul>
</div>
);
}
}
export default graphql(getBooksQuery)(BookList);
但是我收到以下错误。
[Network error]: ServerParseError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
我已经用 nodejs 和 graphql 配置了后端服务器。 但我可以轻松地在我的浏览器中打开“http://localhost:4000/graphql/”发送下面的查询
{ books{ name id } }
并从数据库中获取数据。有谁知道问题出在哪里?
我已经弄清楚了问题,我指出我的客户错了 URL。