0
votes
import React, { Component } from "react";
import axios from "axios";
class Verifry extends Component {
  constructor(props) {
    super(props);
    this.state = {
      s: "0",
      user: [],
    };
  }

/* has title as attribute within the res.data*/ async componentDidMount() { await axios .get(http://10.0.0.106:8080/kuwait_elections/api/about_us) .then((res) => { const persons = res.data; this.setState({ user: persons.data.title, s: "4" }); console.log(this.state.user); }); } componentDidUpdate() { // this.state.user.map((u) => { // return

  • u
  • ; // }); } render() { return (
      {this.state.user.map((t) => { return
    • {t.title}
    • ; })}
    ); } }
    export default Verifry;
    
    1
    can you please format your code snippet?Shyam

    1 Answers

    0
    votes

    Seems your return is not correct. It should be like this.

    {
      this.state.user.map(({title}) => { 
        return { title };
      })
    }
    

    Note: Please format your code properly to make it easier to understand.