Search code examples
javascriptreactjsnext.jsfrontendsanity

Getting this error in React while trying to build url for an image in sanity


Server Error Error: Malformed asset _ref 'e173af30-fd2d-42ed-a364-d92a2cddf32c'. Expected an id like "image-Tb9Ew8CXIwaY6R1kjMvI0uRR-2000x3000-jpg".enter image description here enter image description here

Can someone help me to fix it please... actually i'm still learning while making this project


Solution

  • Try adding .url() to the src.

    src={urlFor(image).url()}
    

    If the image you're trying to render is stored directly on sanity as a link then you don't need urlFor().

    src={image}