title: node https.get how to validate 401
body: <p>I need to validate the 401 which is an authorization error, but need to display an alert, this is my code but I don't know how to send this to the front.</p>
  <pre><code>}).on('end', () =&gt; {
                      console.log('response.statusCode ', response.statusCode );
                      if (response.statusCode &lt; 200 || response.statusCode &gt; 299) {
                          console.log('error section');
                          error = new Error('Request Failed.' + `Status Code: ${response.statusCode}`)
                          console.log('error-&gt;', error);
                          res.send(error);
                      }else{
                          console.log('success section');
                          res.send(JSON.parse(data.toString()));
                      }
                  });
  </code></pre>