title: POST request using fetch with async/await on submit
body: <p>I want to POST to a login form using React JSX and JWT API auth already installed. I don't want to use axios post, instead I want to use the hooks method useState, useEffect with async/await and onFormSubmit function. How do I POST the data values username and password between the state and effect. thanks</p>
  <pre><code>const [login, setLogin] = useState({
      username: '',
      password: '',
      userNiceName: '',
      userEmail: '',
      loggedIn: false,
      loading: false,
      error: ''
  })
  
  
  useEffect(() =&gt; {
  
  }, [])
  
  const postData = async () =&gt; {
      const response = await fetch('http://localhost:8888/react/wp-json/jwt-auth/v1/token', requestOptions )
      const login = await response.json()
      const requestOptions = {
              method: 'POST',
             headers: { 'Content-Type': 'application/json' },
              body: JSON.stringify(data)
      }
  
  
  const onFormSubmit = e =&gt; {
      e.preventDefault()
      const data = {
          username: e.target[0].value,
          password: e.target[2].value,
      }
  </code></pre>