Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
Error when inserting a value to an array in Sanity.io

So I'm using sanity .patch() to insert data inside an array. But I'm continously getting this error:

Error: insert(at, selector, items) takes an "at"-argument which is one of: "before", "after", "replace"

Here is my code for reference:

post.js

// ...
{
        name: "peopleLiked",
        title: "People Liked",
        type: "array",
        of: [{ type: "string" }]
}

Where I'm using it:

client.patch(id)
            .insert({
                "before": `peopleLiked.array[0]`,
                
                "items": [auth.currentUser.displayName]
            })

Can anyone help.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The insert syntax is wrong, looking at the docs it should be along the lines of:

client.patch(id).insert('before', 'peopleLiked', [{"items": [auth.currentUser.displayName]}])

I'm not familiar with Sanity but looks like you may also need to .commit() after the patch

Hope that helps

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda