Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

119
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda