# Passing query params with auth0-next js?

**URL:** <https://community.auth0.com/t/passing-query-params-with-auth0-next-js/82455>\
**Category:** Get Help\
**Tags:** api, javascript, nextjs, auth0\
**Created:** [April 27, 2022, 3:55am UTC](https://community.auth0.com/t/passing-query-params-with-auth0-next-js/82455 "2022-04-27T03:55:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chemmso](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@chemmso](https://community.auth0.com/u/chemmso)\
**Post date:** [April 27, 2022, 3:55am UTC](https://community.auth0.com/t/passing-query-params-with-auth0-next-js/82455/1 "2022-04-27T03:55:06Z")

</div>

So, I ended up getting stuck on this nextjs project and my knowledge of next and JS is extremely minimal as is my auth0 knowledge. I was wondering if anyone could suggest how to pass query parameters to the first block of code below?

Any help would be greatly appreciated.

/pages/api/my/user

```auto
import { getAccessToken, withApiAuthRequired } from '@auth0/nextjs-auth0';

export default withApiAuthRequired(async function shows(req, res) {
  try {
    const { accessToken } = await getAccessToken(req, res, {
      scopes: ['profile']
    });
    const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/v1/my/user`, {
      headers: {
        Authorization: `Bearer ${accessToken}`
      },
    });

    const shows = await response.json();

    res.status(200).json(shows);
  } catch (error) {
    res.status(error.status || 500).json({ error: error.message });
  }
});

```

And here’s the snippet that fetches the above:  
/pages/profile

```auto
  const [state, setState] = useState({ isLoading: false, response: undefined, error: undefined });

  useEffect(() => {
    callApi();

  }, []);

  const callApi = async () => {
    setState(previous => ({ ...previous, isLoading: true }))

    try {
      const response = await fetch(`/api/my/user`);
      const data = await response.json();
      
      setState(previous => ({ ...previous, response: data, error: undefined }))
    } catch (error) {
      setState(previous => ({ ...previous, response: undefined, error }))
    } finally {
      setState(previous => ({ ...previous, isLoading: false }))
    }
  };

  const { isLoading, response, error } = state;

```

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 27, 2022, 5:21pm UTC](https://community.auth0.com/t/passing-query-params-with-auth0-next-js/82455/3 "2022-04-27T17:21:58Z")

</div>

Hi @chemmso,

You simply need to append them to the end of the url.

This GH issue has examples: [How to pass url query params? · Issue #256 · github/fetch · GitHub](https://github.com/github/fetch/issues/256)

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [June 28, 2022, 10:30pm UTC](https://community.auth0.com/t/passing-query-params-with-auth0-next-js/82455/4 "2022-06-28T22:30:02Z")

</div>


