title: ("[object Promise]") cannot be serialized as JSON
body: <p>Full error:</p>
  <blockquote>
  <p>Error: Error serializing <code>.b</code> returned from <code>getStaticProps</code> in &quot;/&quot;.
  Reason: <code>object</code> (&quot;[object Promise]&quot;) cannot be serialized as JSON.
  Please only return JSON serializable data types.</p>
  </blockquote>
  <p>I am trying to call one of my functions that retrieves some data from an API endpoint however when trying to pass this data to props I get an error. I am not exactly sure what I am doing wrong as the fetch call works if its within GetStaticProps but I want all my logic for fetch calls to exist within a separate js page to reduce redundancies, however when doing so this error is created.</p>
  <pre><code>export async function getStaticProps() {
  
  let b = WordpressService.getPageByIdTest(50);
  
  return {
      props: {
          b: b,
      }, 
      revalidate: 30     
  }
  </code></pre>
  <p>}</p>
  <pre><code>const WordpressService = {
      async getPageByIdTest(id) {
      
          const resIndexPage = await fetch(`${url}pages/${id}`);
          const indexPageData = await resIndexPage.json();
  
          return indexPageData;
      }
  }
  </code></pre>