# Authenticate React fetch with auth0

**URL:** <https://community.auth0.com/t/authenticate-react-fetch-with-auth0/42753>\
**Category:** Get Help\
**Tags:** jwt, auth0\
**Created:** [May 11, 2020, 1:39pm UTC](https://community.auth0.com/t/authenticate-react-fetch-with-auth0/42753 "2020-05-11T13:39:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kosvrouvas](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kosvrouvas/32/21201_2.png) [@kosvrouvas](https://community.auth0.com/u/kosvrouvas)\
**Post date:** [May 11, 2020, 1:39pm UTC](https://community.auth0.com/t/authenticate-react-fetch-with-auth0/42753/1 "2020-05-11T13:39:26Z")

</div>

Hello, I’m new to auth0.

I have a fetch() search form that users search for something and the API returns some fields. What I’m trying to do is, when a user is logged out, I want the API to return only some of the fields, when logged in, all of them.

is this possible with auth0?

---

<div class="post-metadata">

**Author:** ![lucas.sonich](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lucas.sonich/32/17240_2.png) [@lucas.sonich](https://community.auth0.com/u/lucas.sonich)\
**Post date:** [May 11, 2020, 7:10pm UTC](https://community.auth0.com/t/authenticate-react-fetch-with-auth0/42753/2 "2020-05-11T19:10:45Z")

</div>

Hello! Welcome to our community.

This would be limited by your application because we only provide the service to perform the authentication.

Thanks.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [May 12, 2020, 9:14am UTC](https://community.auth0.com/t/authenticate-react-fetch-with-auth0/42753/3 "2020-05-12T09:14:48Z")

</div>

Hey there @kosvrouvas!

Can you provide like a real life scenario so we can understand your case in a better way? Thank you!

---

<div class="post-metadata">

**Author:** ![kosvrouvas](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kosvrouvas/32/21201_2.png) [@kosvrouvas](https://community.auth0.com/u/kosvrouvas)\
**Post date:** [May 12, 2020, 11:20am UTC](https://community.auth0.com/t/authenticate-react-fetch-with-auth0/42753/4 "2020-05-12T11:20:53Z")

</div>

Hey there.

I’m calling an API with fetch like this:

```
  apiCall() {
    fetch("http://example.com/json", {
      method: "POST",
      headers: {
        Accept: "application/json",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
           question: this.state.searchValue,
      }),
    })
      .then((response) => {
        return response.json();
      })
      .then((jsonData) => {
        this.setState({ posts: jsonData.results.posts });
      });
  }

```

And I’m getting a result of posts with fields like content, title, author etc in a JSON format.

I need free users to only get some of these fields back. Now, if the user is logged in (so we have a user id/token) the response should contain all fields

---

<div class="post-metadata">

**Author:** ![Boreham](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/boreham/32/12826_2.png) [@Boreham](https://community.auth0.com/u/Boreham)\
**Post date:** [May 15, 2020, 7:26am UTC](https://community.auth0.com/t/authenticate-react-fetch-with-auth0/42753/5 "2020-05-15T07:26:23Z")

</div>

In the APIs section of the Auth0 dashboard, click **Create API**. Provide a name and an identifier for your API. You will use the identifier later when you’re configuring your Javascript Auth0 application instance [mcdvoice](https://mcdvoice.me/)
