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

I just encountered this error when trying to create an array with two types. Is this not possible, or am I doing something wrong? 😬

1 replies
Last updated: Jan 27, 2021
I just encountered this error when trying to create an array with two types. Is this not possible, or am I doing something wrong? 😬
Jan 27, 2021, 8:34 PM
It's a bit subtle, but
image
 is an actually an object type, and you can't mix primitive types (like numbers and strings) with object types. That means that you have to put your
string
 inside of an object. So:
of: [ { type: 'object', fields: [{type: 'string', name: 'text'}]}, { type: 'image' }]

Jan 27, 2021, 8:36 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?