title: How to catch 401 error using fetch method of javascript
body: <p>I need to catch error 401 Code of response so that I can retry after getting a new token from token endpoint. I am using fetch method get data from API.</p>
  
  <pre><code>   const request: Request = new Request(url.toString(), {
          headers: this.defaultRequestHeaders,
          method: "get",
          mode: "cors"
      });
  
     const headers: Headers = new Headers({
          "Accept": "application/json",
          "Content-Type": "application/json"
      });
  
     fetch(request)
          .then(function(response)
           {
            ///Logic code
           })
          .catch(function(error)
          {
            ///if status code 401. Need help here
          });
  </code></pre>