title: How can I get the value of fetch async in then statement when I am using Swal?
body: <p>This is my source code. I am using <a href="https://sweetalert2.github.io/" rel="nofollow noreferrer">sweetalert2.all.min.js</a>  to use <code>swal</code> popup. Now I have a question, How can I access the returned value from API endpoint in <code>then</code> statement? I also mark it in the source code.
  This is the source:</p>
  <pre><code>Swal.fire({
          title: 'Welcome',
          text: &quot;Enter Username and Password&quot;,
          html:
              '&lt;input id=&quot;username_input&quot; class=&quot;swal2-input&quot; placeholder=&quot;Enter Username&quot;&gt;',
          input: 'password',
          inputPlaceholder: 'Enter Password',
          inputAttributes: {
              autocapitalize: 'off'
          },
          showCancelButton: false,
          confirmButtonText: 'Login',
          showLoaderOnConfirm: true,
          preConfirm: (passwordEntered) =&gt; {
              var usernameEntered = document.getElementById('username_input').value;
              return fetch(&quot;...my_endpoint.../checkusername/&quot; + usernameEntered + &quot;/&quot; + passwordEntered)
                  .then(response =&gt; {
                      response.text().then((val) =&gt; {
                          return val   // **: I need to get this value in * place
                      });
                  })
                  .catch(error =&gt; {
                      return &quot;ERROR&quot;;
                  })
          },
          allowOutsideClick: () =&gt; {
              !Swal.isLoading()
          }
      }).then((result) =&gt; {
          alert(result.value);  // *: I need to access the value from **
      })
  </code></pre>
  <p>So, When I log result's value, I get value of <code>passwordEntered</code> variable.</p>