title: Overwriting an existing command with Cypress
body: <p>I'm trying to <a href="https://docs.cypress.io/api/cypress-api/custom-commands.html#Overwrite-Existing-Commands" rel="nofollow noreferrer">overwrite an existing command in Cypress.io</a>. I'm looking to <a href="https://docs.cypress.io/api/commands/log.html" rel="nofollow noreferrer">log()</a> a route response's <code>status</code> &amp; the route's <code>url</code> to extend the functionality of the built-in <a href="https://docs.cypress.io/api/commands/route.html#Syntax" rel="nofollow noreferrer">route()</a>. Unfortunately, I get this message <code>The route undefined had a undefined status code.</code>  in the <code>console</code>. Note, I'm using the browser's <code>console</code> momentarily. Eventually, I'll use the <code>log()</code> built-in method. This is what I have tried so far:</p>
  
  <pre><code>cypress/support/commands.js
  Cypress.Commands.overwrite('route', (originalFn, response) =&gt; {
    console.log(`The route ${response.url} had a ${response.status} status code.`);
  
    return originalFn(response);
  });
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>I'm getting the route now, but I still don't get <code>response</code> or <code>status</code>. This is my current code:</p>
  
  <pre><code>Cypress.Commands.overwrite('route', (originalFn, url, response) =&gt; {
    console.log(`The route ${url} had ${response} status code`);
    return originalFn(url, response);
  });
  </code></pre>