title: How to pass username and password credentials while fetching data from api in javascript?
body: <p>I am using <a href="http://developer.flowroute.com/api/numbers/v2.0/" rel="nofollow noreferrer">flowroute api</a> and need to fetch data but not sure how to add authentication credentials i.e can be seen when I pass the query url in the browser
  How can I pass it in the javascript.
  I am using wix platform and adding javascript code as given below</p>
  
  <pre><code>// For full API documentation, including code examples, visit http://wix.to/94BuAAs
  import {fetch} from 'wix-fetch';
  $w.onReady(function () {
      fetch('https://api.flowroute.com/v2/numbers/available?starts_with=800&amp;limit=3?',{method: 'get',auth:{user:'28288282', pass:'099299292991'}})
        .then( (httpResponse) =&gt; {
         console.log(httpResponse.ok);
      if (httpResponse.ok) {
  
        return httpResponse.json();
      } else {
        return Promise.reject("Fetch did not succeed");
  
  
  
    }
    } )
    .then(json =&gt; console.log(json))
    .catch(err =&gt; console.log(err));
  
      //TODO: write your page related code here...
  
  
  
  });
  </code></pre>
  
  <p>what is the correct method to pass username and password to the API so I can get a json response instead of current <strong>401 Unauthorized response status</strong></p>
  
  <p><a href="https://api.flowroute.com/v2/numbers/available?starts_with=800&amp;limit=3" rel="nofollow noreferrer">https://api.flowroute.com/v2/numbers/available?starts_with=800&amp;limit=3</a>
  <a href="https://i.stack.imgur.com/XuavG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XuavG.png" alt="enter image description here"></a></p>
  
  <p>Updating my Answer to show you the Network Call Details 
  Request &amp; Response headers ae as given bwlow in the screenshot
  <a href="https://i.stack.imgur.com/EpCjT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EpCjT.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/wjfzh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wjfzh.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/4YUgi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4YUgi.png" alt="enter image description here"></a></p>