title: Appending param to api request?
body: <p>I have a method that is called, passed a file name, and then makes an API call to the back end to get a preauthorized link. I am attempting to append the parameter (filename) to the end of the URL, but it is causing my API request to 404. </p>
  
  <p>How can I correctly pass a parameter with my API request and get back the preauthorized URL in the response? </p>
  
  <p><strong>My file names may also contain spaces, which I suspect may have something to do with the request returning a 404.</strong></p>
  
  <p>This is the call on my <strong>front end</strong>:</p>
  
  <pre><code>getPreauthorizedLink(fileName) {   
      console.log(fileName);
      var fileName = fileName;
      var url = 'reportPresignedURL/' + fileName;
      fetch(config.api.urlFor(url))
      .then((response) =&gt; response.json())
      .then((url) =&gt; {
          console.log(url);
      });
  }
  </code></pre>
  
  <p>And this is the implementation of that API on the <strong>back end</strong>:</p>
  
  <pre><code>reports.get('/reportPresignedURL/:fileName', async (req, res) =&gt; {
      const subscriberID = req.query.subscriberID || 0;
  
      var AWS = require('aws-sdk');
  
      var s3 = new AWS.S3();
  
      var params = { 
          Bucket: config.reportBucket,
          Key: req.params.fileName,
          Expires: 60 * 5
      }
  
      try {
          s3.getSignedUrl('getObject', params, function (err, url) {
              if(err)throw err;
              console.log(url)
              res.json(url);
          });
      } catch (err) {
          res.status(500).send(err.toString());
      }
  });
  </code></pre>
  
  <p>I have tried isolating the issue down to just how I am passing the param by doing the following on the <strong>front end</strong>:</p>
  
  <pre><code>  getPreauthorizedLink(fileName){
  
      console.log(fileName);
  
      var fileName = fileName;
  
      var testFileName = 'test';
  
      var url = 'reportPresignedURL/' + testFileName.replace(/ /g, '%20').replace(/\//g, '%2F');
  
      fetch(config.api.urlFor(url))
      .then((response) =&gt; response.json())
      .then((url) =&gt; {
  
        console.log(url);
    });
    }
  </code></pre>
  
  <p>This is how I specify the API route in config.js:</p>
  
  <pre><code>reportPresignedURL: '/reports/reportPresignedURL',
  </code></pre>
  
  <p>I have also tried specifying it like this:</p>
  
  <pre><code>reportPresignedURL: '/reports/reportPresignedURL/:fileName',
  </code></pre>
  
  <p>For Your Information I have added this API route to my <strong>config.js</strong> in the front end.</p>