imranhsayed / woo-next

:rocket: React WooCommerce theme, built with Next JS, Webpack, Babel, Node, Express, using GraphQL and Apollo Client
https://codeytek.com/course/woocommerce-with-react-course/
879 stars 260 forks source link

ApolloError: Unexpected token '<' #120

Open pdenissen opened 1 year ago

pdenissen commented 1 year ago

Hi there,

Today I'm installing this theme for learning about querying Wordpress as a newbie at Next. Now I'm getting this error below. Any idea what is going wrong or where to look at?

wait  - compiling...
event - compiled successfully
event - build page: /next/dist/pages/_error
wait  - compiling...
event - compiled successfully
error - ApolloError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
    at new ApolloError (/Users/pierredenissen/Domains/woo-next/node_modules/@apollo/client/errors/errors.cjs.js:31:28)
    at /Users/pierredenissen/Domains/woo-next/node_modules/@apollo/client/core/core.cjs.js:1493:19
    at both (/Users/pierredenissen/Domains/woo-next/node_modules/@apollo/client/utilities/utilities.cjs.js:963:53)
    at /Users/pierredenissen/Domains/woo-next/node_modules/@apollo/client/utilities/utilities.cjs.js:956:72
    at new Promise (<anonymous>)
    at Object.then (/Users/pierredenissen/Domains/woo-next/node_modules/@apollo/client/utilities/utilities.cjs.js:956:24)
    at Object.error (/Users/pierredenissen/Domains/woo-next/node_modules/@apollo/client/utilities/utilities.cjs.js:964:49)
    at notifySubscription (/Users/pierredenissen/Domains/woo-next/node_modules/zen-observable/lib/Observable.js:140:18)
    at onNotify (/Users/pierredenissen/Domains/woo-next/node_modules/zen-observable/lib/Observable.js:179:3)
    at SubscriptionObserver.error (/Users/pierredenissen/Domains/woo-next/node_modules/zen-observable/lib/Observable.js:240:7) {
  graphQLErrors: [],
  networkError: SyntaxError [ServerParseError]: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
      at JSON.parse (<anonymous>)
      at /Users/pierredenissen/Domains/woo-next/node_modules/@apollo/client/link/http/http.cjs.js:18:25
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
    response: Response {
      size: 0,
      timeout: 0,
      [Symbol(Body internals)]: [Object],
      [Symbol(Response internals)]: [Object]
    },
    statusCode: 404,
    bodyText: '<!DOCTYPE html>\n' +

Thanks for the help!

imlouisblanco commented 1 year ago

Hi! I had the same issue, you have to install the last WooGraphQL plugin version: https://github.com/wp-graphql/wp-graphql-woocommerce/releases/tag/v0.12.0