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?
1 Like
Hello! Welcome to our community.
This would be limited by your application because we only provide the service to perform the authentication.
Thanks.
Hey there @kosvrouvas!
Can you provide like a real life scenario so we can understand your case in a better way? Thank you!
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
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