Prismic API query returning empty object in NextJs

I'm trying to query my documents into a NextJs app using getServerSideProps, and I've followed all of the tutorials in the Prismic documentation (which, I'd like to respectfully add, could probably use a bit of clarity and updating. I found it pretty confusing.) However, no matter how I've queried the documents, I'm only ever receiving an empty object.

I've created a client, like so:

import Prismic from 'prismic-javascript';

export const apiEndpoint = 'https://one-day-marketing.prismic.io/api/v2/';
export const accessToken = '';

export const Client = (req = null) => {
  Prismic.client(apiEndpoint, createClientOptions(req, accessToken));

  const createClientOptions = (req = null, prismicAccessToken = null) => {
    const reqOption = req ? { req } : {};
    const accessTokenOption = prismicAccessToken ? { accessToken: prismicAccessToken } : {};

    return {
      ...reqOption,
      ...accessTokenOption,
    };
  };
};

And have been attempting to query my documents, we'll take homepage as an example, like so:

import React from 'react';
import { Helmet } from 'react-helmet';

import Prismic from 'prismic-javascript';
import { Client } from '../../prismic-configuration';

// tslint:disable no-default-export
export default (index: any) => {
  return (
    <>
      <Helmet title={'Home'} />
      <pre>{JSON.stringify(index)}</pre>
    </>
  );
};

export const getServerSideProps = async () => {
  const client = Client();
  const index = await client.query(Prismic.Predicates.at('document.type', 'homepage'));
  console.log(index);

  return { props: { index } };
}

However, the console.log in the getServerSideProps function, and the stringified JSON are simply returning an empty object {}, and I am at a complete and total loss for how to get these results back. Like I said, the Prismic documentation wasn't as helpful as I'd hoped, so I've been scouring YouTube and the far reaches of the internet to get this working, but I haven't gotten anything so far. What am I doing wrong?

Hi Jesse,

Thanks for contributing to the Prismic community.

I will try to troubleshoot this issue with you, first of all, did you try to use the Restful API to query your data? for the same page? did you get any results?

To learn more about the API browser check this link

Also, it will be very interesting and helpful If we can spot what is confusing in the documentation and improve them if necessary.

Can you please also share with us your repository name (in a private message if nessesery)?

Looking forward to your reply,
Fares

Yes! I have queried my documents in the API browser, and I'm able to return both the HTML and the JSON.

As far as the documentation, it's likely just my own newness with Next, but I think the navigation structure is what got me. It seemed like most of it was related to integrating Slice Machine, and not to actually getting up and running with a Next.js project. That's really the only thought I had.

This issue has been handled in a private thread, the shared code seems ok, and the issue might be related to missing authentication token.
We recommend to share the whole project code to troubleshoot further.