Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Issue with undefined mainImage in Nuxt app's Sanity Studio

5 replies
Last updated: Jul 24, 2020
Good morning!any idea why I'm getting this ?
here on a Nuxt App. Images are rendered fine in the frontend. Yet opening the studio at

http://localhost:3333/  I have:
Uncaught error

mainImage is not defined

Stack:

ReferenceError: 
    at Object.<anonymous> (<http://localhost:3333/static/js/app.bundle.js:2658:18>)
    at __webpack_require__ (<http://localhost:3333/static/js/vendor.bundle.js:713:30>)
    at fn (<http://localhost:3333/static/js/vendor.bundle.js:118:20>)
    at Object.<anonymous> (<http://localhost:3333/static/js/app.bundle.js:152321:38>)
    at __webpack_require__ (<http://localhost:3333/static/js/vendor.bundle.js:713:30>)
    at fn (<http://localhost:3333/static/js/vendor.bundle.js:118:20>)
    at Object.<anonymous> (<http://localhost:3333/static/js/app.bundle.js:152294:49>)
    at __webpack_require__ (<http://localhost:3333/static/js/vendor.bundle.js:713:30>)
    at fn (<http://localhost:3333/static/js/vendor.bundle.js:118:20>)
    at Object.<anonymous> (<http://localhost:3333/static/js/app.bundle.js:152212:26>)

(Your browsers Developer Tools may contain more info)

☺️however "mainImage" is defined in schemas, so that it renders in the frontend. Yet there is this issue in the studio.
any idea?
thanks!
Jul 24, 2020, 7:27 AM
Hi Deborah! Could it be that you have an incomplete schema file anywhere? Feel free to share your schema folder (zip) in DM if you prefer 🙂
Jul 24, 2020, 10:35 AM
Hi
user M
thank you! maybe easier to look at the github repo: https://github.com/purplegreen/adada--Nuxt-Sanitity-io/blob/master/mystudio/schemas/post.js
Jul 24, 2020, 10:57 AM
However the problem is occurring -I have the impression- after importing GSAP in Nuxt.Js... which is problematic. So if the Schemas are fine, the problem may lay there. Thank you for looking into it
Jul 24, 2020, 11:02 AM
On this line (L19) you’re including
mainImage
in your schema: https://github.com/purplegreen/adada--Nuxt-Sanitity-io/blob/master/mystudio/schemas/schema.js#L19 . However, it’s not actually imported at the top, unlike for example
import blockContent from "./blockContent";
. Also, there’s no
mainImage.js
file in your
schemas
folder in this case. Creating the schema file and importing it should resolve the error 🙂
Jul 24, 2020, 11:06 AM
user M
Thank you very much Peter! 🌈
Jul 24, 2020, 11:11 AM

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?