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

434
Visualizações
TypeError: Cannot read properties of null (reading 'find')"

I'm trying to push an object to an array using vuex but i'm getting this error. I don't know why in Edge works great, but in Chrome and Opera it doesn't.

TypeError: Cannot read properties of null (reading 'find')"

Vuex store:

export default {
  namespaced: true,
  state: {
    shoppingCartItems: [], 
  },
  mutations: {
    SET_ITEM(state, payload) {
      if (state.shoppingCartItems.find(item => item.type === 'custom-item')) {
        state.shoppingCartItems.push(payload)
      } else if (state.shoppingCartItems.find(item => item.name === payload.name)) {
        const index = state.shoppingCartItems.findIndex(item => item.name === payload.name)
        const value = payload.quantity
        state.shoppingCartItems[index].quantity += value
      } else {
        state.shoppingCartItems.push(payload)
      }
    },
  }
}

In SET_ITEM I'm checking if the payload is an item that already is in the array so instead of adding again, it sums 1 to this specific item. And again, in Edge it's working perfectly, but in Chrome everything seems to be broken.

Example of payload that SET_ITEM is receiving:

payload = {
dimensions: "30x10cm"
extraLine: 2
extraQuote: "no"
frases: [__ob__: Observer]
image: ""
name: "custom-item"
namesQuantity: 1
names: [{…}, __ob__: Observer]
price: 180
quantity: 1
type: "custom-item"
}

enter image description here

about 4 years ago · Juan Pablo Isaza
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