Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!