Why 'pages', 'nbPages', 'hits' response not show when I console.log(hits)

Code
async getProductFromQuery(query: any) {
    await this.index
      .search(query, {
        hitsPerPage: 20
      })
      .then(({ hits }) => {
        console.log('Algoria: ', hits)
        this.items = hits.map((hits) => ({
          short_name: hits['name'],
          price: hits['price'],
          image: hits['image'],
          id: hits['id']
        }))
      })
      .catch((error) => {
        console.log('No products.', error)
      })
  }
Screenshot

Screen Shot 2564-04-15 at 07.21.42

docs:

those properties are of the response, not of the hits, so you’d need to change your code like this:

this.index.search(query, {hitsPerPage: 20}).then({hits, pages, ...rest}) => console.log(hits, pages, rest))
1 Like

Thank you for you help. :smiley: