šŸ‘‹ Next.js Conf 2024: Come build, party, run, and connect with us! See all events

Issue with API version and GROQ query in Sanity.io resolved successfully.

6 replies
Last updated: Jun 3, 2022
hello everyone
I am trying to groq (what i thought was) a simple array of projects


`*[_type == "projects"]`
it works in vision

DM ME FOR URL PLS

but I notice that my api version is like 2021-10-21 like the docs. not sure how to ensure it says up to date on my side?

also not sure why it's working there and not in my groq.

here's how I call it


  try {
    const domains = await sanity.fetch(await getProjectDomains());
    console.log(domains);
  } catch (error) {
    console.error(error);
  }
and the full error I get is


ClientError: expected ']' following array body
    at onResponse (node_modules/@sanity/client/lib/http/request.js:28:13)
    at applyMiddleware (node_modules/get-it/lib-node/util/middlewareReducer.js:10:15)
    at onResponse (node_modules/get-it/lib-node/index.js:80:22)
    at node_modules/get-it/lib-node/index.js:50:55
    at callback (node_modules/get-it/lib-node/request/node-request.js:67:46)
    at node_modules/get-it/lib-node/request/node-request.js:156:14
    at DestroyableTransform.<anonymous> (node_modules/simple-concat/index.js:8:13)
    at Object.onceWrapper (node:events:509:28)
    at DestroyableTransform.emit (node:events:402:35)
    at DestroyableTransform.emit (node:domain:475:12) {
  response: {
    body: { error: [Object] },
    url: 'DM ME',
    method: 'GET',
    headers: {
      'content-type': 'application/json; charset=utf-8',
      'content-length': '122',
      'x-ratelimit-limit-second': '500',
      'ratelimit-limit': '500',
      'ratelimit-remaining': '499',
      'ratelimit-reset': '1',
      'x-ratelimit-remaining-second': '499',
      'x-sanity-shard': 'gcp-eu-w1-01-prod-1028',
      'x-served-by': 'gradient-query-7566c8dfb4-9lk2l',
      date: 'Fri, 03 Jun 2022 19:32:04 GMT',
      vary: 'Origin',
      xkey: 'project-PROD_ID, project-PROD_ID-production',
      via: '1.1 google',
      'alt-svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000',
      connection: 'close'
    },
    statusCode: 400,
    statusMessage: 'Bad Request'
  },
  statusCode: 400,
  responseBody: '{\n' +
    '  "error": {\n' +
    `    "description": "expected ']' following array body",\n` +
    '    "end": 14,\n' +
    '    "query": "[object Object]",\n' +
    '    "type": "queryParseError"\n' +
    '  }\n' +
    '}',
  details: {
    description: "expected ']' following array body",
    end: 14,
    query: '[object Object]',
    type: 'queryParseError'
  }
}
Jun 3, 2022, 7:38 PM
Hi Austin. It looks like
getProjectDomains()
is returning
[object Object]
rather than a GROQ query.
Jun 3, 2022, 7:47 PM
shoot.
Jun 3, 2022, 8:04 PM
šŸ˜…
Jun 3, 2022, 8:04 PM
Please let us know if you happen to get this resolved or if it remains an error, in which case we can investigate further.
Jun 3, 2022, 8:19 PM
yes I got it solved, sorry about that.
Jun 3, 2022, 8:23 PM
No problem! Glad to hear it. šŸ™Œ
Jun 3, 2022, 8:24 PM

Sanityā€“ build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?