✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Cannot Import JSON File From the Studio?

2 replies
Last updated: Sep 2, 2020
Hello!
Seems like I can not import json file from the Studio?
I'd like to use
@sanity/client
from the browser.For that I need to provide project id.
It is
sanity.json
. I'd like to keep it there to have only one source of truth.But when I try to import it from my Custom Input Component, I'm getting

Error in ./sanity.json
Syntax error: <path to studio>/sanity.json: Unexpected token, expected ";" (2:8)

  1 | {
> 2 |   "root": true,
    |         ^
I believe sanity does not allow to import json and tries to interpret it like a regular js file.

Is there any solution for such case?
Sep 2, 2020, 2:13 PM
I think
import client from 'part:@sanity/base/client'
will get you the configured client in studio code, so you might not need to read the project id.
Sep 2, 2020, 2:34 PM
Amazing!Thanks man!
Sep 2, 2020, 2:37 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?