react-apollo Error: [Network error]: ServerParseError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

Viewed 3738

I want to send a request to the server via apollo and get a query:

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);

But I am getting the following error.

[Network error]: ServerParseError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

I have configured backend server with nodejs and graphql. But I can easily open "http://localhost:4000/graphql/" in my browser send below query


{
    books{
        name
        id
    }
}

and fetch data from the db. Does anyone know where the problem is?

1 Answers

I have figured out the issue and I am pointing out my client at the wrong URL.

Related