text: 'use strict';
  
  const AWS = require('aws-sdk'); // eslint-disable-line import/no-extraneous-dependencies
  
  const dynamoDb = new AWS.DynamoDB.DocumentClient();
  const params = {
    TableName: process.env.DYNAMODB_TABLE,
    FilterExpression: "sort = :sort",
    ExpressionAttributeValues: {
      ':sort': 'poll-details'
    }
  };
  
  module.exports.list = (event, context, callback) => {
    // fetch all from the database
    dynamoDb.scan(params, (error, result) => {
      // handle potential errors
      if (error) {
        console.error(error);
        callback(null, {
          statusCode: error.statusCode || 501,
          headers: {
            'Access-Control-Allow-Origin': '*',
            'Access-Control-Allow-Credentials': true,
          },
          body: JSON.stringify({ message: 'Couldn\'t fetch the items.' }),
        });
        return;
      }
  
      // create a response
      const response = {
        statusCode: 200,
        headers: {
          'Access-Control-Allow-Origin': '*',
          'Access-Control-Allow-Credentials': true,
        },
        body: JSON.stringify(result.Items),
      };
      callback(null, response);
    });
  };
  