[my code](https://i.stack.imgur.com/OnEl7.png)

```
export const getServerSideProps: GetServerSideProps = async () => {
  const ref = collection(db, "books");
  const results = [];

  const unsub = onSnapshot(ref, (snapshot) => {
    snapshot.forEach((doc) => {
      results.push({ ...doc.data(), id: doc.id });
    });
    //here i get the results
    console.log(results)
  });

  // here is empty
  console.log(results)

  return {
    props: {
      books: results,
    },
  };
};

```

I'm trying to get the real time data from firestore database on the `getServerSideProps` function, inside the snapshot I can get the results, but when it's outside the array it's empty and I can't pass to props.