Nuxt js useFetch limit items from hackernews API

193 Views Asked by At

I need limit items from hackernews API.How can I do that? Code is:

<template>

    <p>Products</p>
<div>
  <div class="grid grid-cols-4 gap-5">
    <div v-for="s in results" :key="story">
      <ProductCard :story="s"/>
    </div>
  </div> 
</div>
</template>
<script setup>
  definePageMeta({
    layout: "products"
  })

  const { data: stories } = await useFetch('https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty')
  

  </script>

I tried:

  const { data: stories } = await useFetch('https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty').limit(1000)

but no result.

1

There are 1 best solutions below

0
MrXQ On

according to this there is a default limit of 500 items but there is no option to limit the items you will get, you can store the whole 500 items in an array and display the number of items you want by changing the array using map,for loop filter etc ...