How can I limit an object size before it is looped in vue/nuxt?

siumhossain

sium_hossain

Posted on August 8, 2022

How can I limit an object size before it is looped in vue/nuxt?

Sometimes for design requirements we have to minimize response object size or we can say response data. More clearly - Suppose, from API we receive 40 objects as response but I need only four of them. That's the one of reason GraphQL invented. GraphQL provide only those amount of data which is needed. Whatever we can slice our total response into our desire amount before printing by simply put array slice functionality in v-for loop-

v-for="obj in obj.slice([from:int value],[to:int value])

v-for="(i,index) in i.slice(0,4)" :key="index"
Enter fullscreen mode Exit fullscreen mode

Thank you 💓

💖 💪 🙅 🚩
siumhossain
sium_hossain

Posted on August 8, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related