Auth0 Home Blog Docs

How do i use the body after get users from Management API

management-api
users
react
body
search

#1

I’am an beginner in auth and react,and i faced some problems,
After I called the API =>List or search users ,GET/api/v2/users.This endpoint can be used to retrieve a list of users.

i get the data from body,which is current ,
but the body information like body.name or body"email"] is undefined .

I’am confuse how to get user information after i called the API.
I hope someone will help me, I will be very grateful.


#2

i think i find the anwser :JSON.parse ,
and response type is an object array


#3

As you mentioned in the follow-up comment, the response of the endpoint to list/search users will be a JSON array.

As an additional note, if you are interested in only one actual user and you know its identifier then you may wan to use the Get a user by ID endpoint instead as that will return a single user in a JSON object.


#4

Thank @jmangelo response.
I have solved my problem,
The SPA need to add some condition to use JSON.parse.
Here’s my snippet code.
{
b1=JSON.parse(body)
this.setState({b1})
const { b1 } = this.state
if(b1[0]!==undefined)
{
return(

{b1[0].name}


}
}
and b1[0].name is work


#5