title: NextJS and Auth0 how to get bearer token for api requests
body: <p>I don't know how to add bearer token header to my API call in fetcher to recieve data becasue I'm checking JWT token on backend...</p>
  <p>Fetcher code:</p>
  <pre><code> const fetcher = async () =&gt; {
        const response = await fetch(api); //I need to add bearer token headers to this api request or else it's 401 
        const data = await response.json();
  
      const props = {
          data: data
        };
    return props;
  };
  </code></pre>
  <p>This is data fetching code</p>
  <pre><code>    const {data, error} = useSWR(&quot;data&quot;, fetcher);
      
        if (error) return &lt;div&gt;oops... {error.message}&lt;/div&gt;;
        if (data === undefined) return &lt;div&gt;Loading...&lt;/div&gt;;
        console.log(accessToken);
        return &lt;div&gt;{data}&lt;/div&gt;;
  </code></pre>
  <p>I found a piece of code in some article which said I needed to add this:</p>
  <pre><code> const {accessToken} = getAccessToken({
      scopes: [&quot;read:shows&quot;], // I don't know what is this scope I just pasted it...
    });
  </code></pre>
  <p>But accessToken returns error that it can be retrieved only on server side part...</p>