0
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? Commented Nov 1, 2020 at 16:15

    1 Answer 1

    0

    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.

    Sign up to request clarification or add additional context in comments.

    Comments

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.