title: Using Project Expressions in Dynamo DB
body: <p>I have a DynamoDB table and I am trying to just get one column from the table. More specifically I just want distinct values from a column.</p>
  <p>I am using AWS Amplify and have setup an API to query the DynamoDB table.</p>
  <p>The get method in the API is as follows.
  where</p>
  <ol>
  <li>tableName - is a variable that contains the name of the table.</li>
  <li>Listing_Location is the column I want to retrieve from the table.</li>
  </ol>
  <pre><code>app.get(path, function (req, res) {
  
    if (userIdPresent) {
      req.body['userId'] = req.apiGateway.event.requestContext.identity.cognitoIdentityId || UNAUTH;
    }
  
    var queryItemParams = {
      TableName: tableName,
      ProjectionExpression: &quot;#listing_location&quot;,
      ExpressionAttributeNames = { 
        '#listing_location': 'Listing_Location'
      }
    };
  
    dynamodb.scan(queryItemParams, (err, data) =&gt; {
      if (err) {
        res.statusCode = 500;
        res.json({ error: 'Could not fetch listing locations : ' + err });
      } else {
        res.json(data.Items);
      }
    });
  });
  </code></pre>
  <p>from the front end React application I make the following get request, where
  apiName is the variable which has the API name.
  path is the api endpoint to make the get request.
  and I am importing API like this</p>
  <pre><code>import { Amplify, API } from 'aws-amplify';
  </code></pre>
  <pre><code>  getAllLocations = () =&gt; {
      console.log(&quot;in getAllLocations&quot;);
      API.get(apiName, path).then(response =&gt; {
        console.log(response);
      });
    }
  </code></pre>
  <p>Can you help me understand what I am doing wrong.</p>