Join our next Developer Virtual Meetup – Live Q&A, Project Showcase, Swag raffle, and more 🔥

Uncaught Error: Network Error While Attempting to Reach

3 replies
Last updated: Aug 7, 2020
I'm having trouble with the sanity javascript sdk in nextjs. Other calls work (see the movies json) but the sanity calls only work if I make them in getServerSideProps.

Seems like the sdk doesnt play so well with nextjs. Is that expected?

Any help appreciated. Thanks

I'm getting
Uncaught Error: Network error while attempting to reach*%5B_type%20%3D%3D%20%22candidate%22%20%26%26%20_id%20%3D%3D%20%24cid%5D%20%7B%0A%20%20%20%20%20%20transcript%2C%0A%20%20%20%20%7D%5B0...1%5D%0A%20%20%20%20&%24cid=%22cbadb288-9700-47c5-a99f-78f7b990f77e%22

async componentDidMount() {
    const transcriptQuery = `*[_type == "candidate" && _id == $cid] {
    const data = await fetch('<').then(response> => response.json());
    // const transcript = await sanity.fetch(transcriptQuery, { cid: 'cbadb288-9700-47c5-a99f-78f7b990f77e' });
    // console.log(transcript);

Aug 7, 2020, 3:45 PM
Actually its not just through the sdk, its any call that does not originate from the getServerSideProps initial method
Aug 7, 2020, 3:48 PM
Could it be a CORs issue?
Aug 7, 2020, 3:48 PM
seems that was it 🤦.Thanks.
Aug 7, 2020, 3:55 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?