title: Can I pass a parameter into a WebSocket connection with AWS API Gateway?
body: <p>Following this example project: <a href="https://github.com/aws-samples/simple-websockets-chat-app" rel="nofollow noreferrer">https://github.com/aws-samples/simple-websockets-chat-app</a></p>
  <p>The onconnect method looks like this:</p>
  <pre class="lang-js prettyprint-override"><code>const AWS = require('aws-sdk');
  
  const ddb = new AWS.DynamoDB.DocumentClient({ apiVersion: '2012-08-10', region: process.env.AWS_REGION });
  
  exports.handler = async event =&gt; {
    const putParams = {
      TableName: process.env.TABLE_NAME,
      Item: {
        connectionId: event.requestContext.connectionId
      }
    };
  
    try {
      await ddb.put(putParams).promise();
    } catch (err) {
      return { statusCode: 500, body: 'Failed to connect: ' + JSON.stringify(err) };
    }
  
    return { statusCode: 200, body: 'Connected.' };
  };
  </code></pre>
  <ol>
  <li><p>How can I see what other fields this <code>event</code> object has? I can't find the documentation.</p>
  </li>
  <li><p>Can I pass in a parameter from the client when connecting to the websocket? Like <code>wss://path.to.socket/someparameter</code> and how do I access it from this <code>event</code> object?</p>
  </li>
  </ol>
  <p>I want to add another parameter to the database:</p>
  <pre class="lang-js prettyprint-override"><code>const putParams = {
    TableName: process.env.TABLE_NAME,
    Item: {
      connectionId: event.requestContext.connectionId,
      someparameter: event.someparameter               // &lt;-- What's the right way?
    }
  };
  </code></pre>
  <p>Thanks!</p>