title: Nuxt serverMiddleware get json from API
body: <p>Instead of getting redirects from 301.json I want to make a request to my api which returns my json.</p>
  
  <p>I am using the <code>@nuxtjs/axios</code> module.</p>
  
  <pre><code>const redirects = require('../301.json');
  
  export default function (req, res, next) {
  
      const redirect = redirects.find(r =&gt; r.from === req.url);
  
      if (redirect) {
          console.log('redirect: ${redirect.from} =&gt; ${redirect.to}');
          res.writeHead(301, { Location: redirect.to });
          res.end();
      } else {
          next();
      }
  }
  </code></pre>