[Vuejs]-In vue.js i am trying to get row count but it returning null

0👍

This is because when you return a property in asyncData, you should not have it in data property of the component instance, instead the later will override the returned with asyncData.

  <script>
     import axios from "axios";
     export default {
      async asyncData({ $axios }) {
         let { data } = await $axios.$get("/Businessregisterlist");
         // console.log(response)
         return {
           registerlist: data,
         };
       },
       computed: {
         resultCount() {
           return Object.keys(this.registerlist).length;
         },
       },
     };
     </script>
<template>
       <div>
         <p>{{ resultCount }}</p>
       </div>
  </template>
     
   

Leave a comment