-3

I want to get data from an API , But when I log the data , it returns [ object Object]

 componentDidMount() {
  axios
   .get("https://jsonplaceholder.typicode.com/users")
   .then((response) => response.data
   )
   .then((users) => {
    this.setState({ Robots: users });
   });
 }

it gives me an Error when i try to filter the Robots object :

const filteredRobots = this.state.Robots.filter((robot) => {
   return robot.name
    .toLowerCase()
    .includes(this.props.SearchField.toLowerCase());
  });```

1 Answers1

-1

What do you need two .then for? That's probably where the object stops being an object.

componentDidMount() {
  axios
   .get("https://jsonplaceholder.typicode.com/users")
   .then((response) => {
     console.log(response.data)
     this.setState({ Robots: response.data })
   });
 }
Mikaels Slava
  • 154
  • 2
  • 7