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

127
Visualizações
Is there a way of displaying my data on Vue Component?

I'm working on a project which i need to fetch "clients" data on a table. The data actually comes, but i can't manage to display it. Here's my template part, where i call for info with a v-for.

<tbody>
 <tr v-for="item in clients" v-bind:key="item.id">
            <td>{{ item.id }}</td>
            <td>{{ item.name }}</td>
            <td>{{ item.email }}</td>
            <td>{{ item.documents.cpf || item.documents.cnpj }}</td>
            <td>{{ item.documents.celular }}</td>
            <td>{{ item.status }}</td>
            <td v-if="item.address">
              {{ `${item.address.localidade} / ${item.address.uf}` }}
            </td>
            <td v-else>-</td>

            <td>
              <a :href="`/ver-cliente/${item.id}`"
                ></a>
            </td> 
</tr>
</tbody>

On my DevTools, the data is shown: enter image description here

Full DevTools with all errors (some of them are from other pages) enter image description here

My script part:

export default {
  data: () => ({
    clients: [],
    paginationData: {
      lastPage: 0,
      currentPage: 1,
    },
    loading: false,
  }),

  methods: {
    getClients(page = 1) {
      this.loading = true;
      this.$api
        .get("/api_v1/clientes", {
          params: { page },
        })
        .then(({ data }) => {
          console.log(data);
          if (data.success) {
            const {
              data: result,
              per_page,
              total,
              last_page,
              current_page,
            } = data.data;
            this.clients = result;
            this.paginationData = {
              perPage: per_page,
              total,
              lastPage: last_page,
              currentPage: current_page,
            };
          }
        })
        .finally(() => (this.loading = false));
    },
  },

  mounted() {
    this.getClients();
  },
};

That' what i managed to do, but it isn't working. Can anyone give me a hint of what am I doing wrong? Sorry for any rookie mistakes.

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

0

It can't find the property cnjp in the item.documents object, so it throws an error. To get rid of that error you can do item.documents?.cnpj so if the property is not in the object, if will be null instead of throwing an error.

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