title: How to pass a property from one function to another in reactjs
body: <p>Im trying to get the email of the user that from the function getFirstApi() and pass it in to getSecondApit() so i can use it as a param in the fetch() request.</p>
  <p><strong>My Code:</strong></p>
  <pre><code> getFirstApi() {
      Auth.currentAuthenticatedUser().then((user) =&gt; {
        this.setState({email: user.attributes.email, formemail: user.attributes.email})
        return email
      });
   }
  
    getSecondApi() {
      fetch(`https://ezha2ns0bl.execute-api.ap-southeast-2.amazonaws.com/prod/userdata?foo=${encodeURIComponent(email)}`)
        .then(res =&gt; res.json())
        .then(
          console.log(&quot;THIS IS RESULT&quot; + email),
          (result) =&gt; {
            this.setState({
              firstname: result.Item.userFirstName,
              middlename: result.Item.userMiddleName,
              surname: result.Item.userLastName,
              city: result.Item.userCity,
              postcode: result.Item.userPostcode,
              state: result.Item.userState,
              about: result.Item.userAbout,
  
              formfirstname: result.Item.userFirstName,
              formmiddlename: result.Item.userMiddleName,
              formsurname: result.Item.userLastName,
              formcity: result.Item.userCity,
              formpostcode: result.postcode,
              formstate: result.Item.userState,
              formabout: result.Item.userAbout,
              
            });
            console.log(&quot;THIS IS RESULT&quot; + result)} ,
        )
    }
  </code></pre>
  <p><strong>My componentDidMount</strong></p>
  <pre><code>   componentDidMount() {
  
      this.getFirstApi();
      this.getSecondApi();
  
    }
  </code></pre>
  <p>This url api call works in my browser, so i assume its what i  need my out come to be.</p>
  <pre><code>https://ezha2ns0bl.execute-api.ap-southeast-2.amazonaws.com/prod/userdata?userEmail=%22gitigol723@hapremx.com%22
  </code></pre>