How to return output from lambda function to web-front on search using APIHow to break/exit from a each() function in JQuery?In Node.js, how do I “include” functions from my other files?How to return value from an asynchronous callback function?How do I return the response from an asynchronous call?how to pass result of $.get to return of another functionHow to pass a querystring or route parameter to AWS Lambda from Amazon API GatewayAmazon Lambda - return docx file - Node.jsAWS DynamoDB deleteTable not working when called from NodeJs 8.10 Lambda FunctionAWS Lambda query with async waterfall in node.js 8.10AWS Lambda and Dynamo db: How to filter the result of scan by multiple parameters?

he and she - er und sie

Did the Russian Empire have a claim to Sweden? Was there ever a time where they could have pursued it?

Does "boire un jus" tend to mean "coffee" or "juice of fruit"?

Would skyscrapers tip over if people fell sideways?

Is it theoretically possible to hack printer using scanner tray?

Could all three Gorgons turn people to stone, or just Medusa?

What are the children of two Muggle-borns called?

Why are symbols not written in words?

Do electrons really perform instantaneous quantum leaps?

What happens if a caster is surprised while casting a spell with a long casting time?

Is leaving out prefixes like "rauf", "rüber", "rein" when describing movement considered a big mistake in spoken German?

German idiomatic equivalents of 能骗就骗 (if you can cheat, then cheat)

Is this house-rule removing the increased effect of cantrips at higher character levels balanced?

Have any large aeroplanes been landed — safely and without damage — in locations that they could not be flown away from?

Why are examinees often not allowed to leave during the start and end of an exam?

What are the advantages and disadvantages of Manhattan-Style routing?

Why do movie directors use brown tint on Mexico cities?

Why did the Apple //e make a hideous noise if you inserted the disk upside down?

Having to constantly redo everything because I don't know how to do it

Why is my 401k manager recommending me to save more?

Two palindromes are not enough

Word ending in "-ine" for rat-like

How can an inexperienced GM keep a game fun for experienced players?

Is my guitar action too high or is the bridge too high?



How to return output from lambda function to web-front on search using API


How to break/exit from a each() function in JQuery?In Node.js, how do I “include” functions from my other files?How to return value from an asynchronous callback function?How do I return the response from an asynchronous call?how to pass result of $.get to return of another functionHow to pass a querystring or route parameter to AWS Lambda from Amazon API GatewayAmazon Lambda - return docx file - Node.jsAWS DynamoDB deleteTable not working when called from NodeJs 8.10 Lambda FunctionAWS Lambda query with async waterfall in node.js 8.10AWS Lambda and Dynamo db: How to filter the result of scan by multiple parameters?













1















I am trying set up a search bar on my web-front that will allow the user to search for data in my dynamodb table using the key and then returns the results to the website.



i tried to create an API POST function that that gives the value of the key that is being searched for to the lambda function. the resultant data from the lambda function is then presented on the web front via API GET.



here is the relevant java script and html code and the relevant code from the lambda function.



thank you very very much to those who chose to help i greatly appreciate it



html



<table id='table' style="width:50%">
<thead>
<tr>
<th>pKey</th>
<th>Message</th>
<th>Password</th>
</tr>
</thead>
<tbody id="myunipolapi">
</tbody>
</table>

<form>
<textarea id="srch" placeholder="Search Data"></textarea>
</form>
<div>
<button id='searchButton'>Search</button>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>


Javascript ajax GET



$(document).ready(function()
$.ajax(
type: 'GET',
url: API_URL,

success: function(data)
$('#myunipolapi').html('');

data.Items.forEach(function(HeartbeatItem)
$('#myunipolapi').append(
'<tr id="TT"><td id="TT">' + HeartbeatItem.pKey + '</td><td id="TT">' + HeartbeatItem.message + '</td><td id="TT">' + HeartbeatItem.password + '</td></tr>'
);
)

);
);



Javascript ajax POST



$('#searchButton').on('click',function() 
$.ajax(
type: 'POST',
url: API_URL,
data: JSON.stringify("search": $('#srch').val()),
contentType: "application/json",

success: function(data)
$('#TT').load('#myunipolapi');

);
);


Lambda



console.log('starting function');
const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient(region: 'eu-west-2');

exports.handler = function(event, ctx, callback)

console.log(event);

var queryParams =
TableName: 'Heartbeat',
Key:
"pKey": event.search

;

docClient.get(queryParams, function(err, data)
if(err)
callback(err, null);
else
callback(null, data);

);
;


API




"message": $input.json('$.message'),
"password": $input.json('$.password'),
"pKey": $input.json('$.pKey'),
"search": $input.json('$.search')










share|improve this question




























    1















    I am trying set up a search bar on my web-front that will allow the user to search for data in my dynamodb table using the key and then returns the results to the website.



    i tried to create an API POST function that that gives the value of the key that is being searched for to the lambda function. the resultant data from the lambda function is then presented on the web front via API GET.



    here is the relevant java script and html code and the relevant code from the lambda function.



    thank you very very much to those who chose to help i greatly appreciate it



    html



    <table id='table' style="width:50%">
    <thead>
    <tr>
    <th>pKey</th>
    <th>Message</th>
    <th>Password</th>
    </tr>
    </thead>
    <tbody id="myunipolapi">
    </tbody>
    </table>

    <form>
    <textarea id="srch" placeholder="Search Data"></textarea>
    </form>
    <div>
    <button id='searchButton'>Search</button>
    </div>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>


    Javascript ajax GET



    $(document).ready(function()
    $.ajax(
    type: 'GET',
    url: API_URL,

    success: function(data)
    $('#myunipolapi').html('');

    data.Items.forEach(function(HeartbeatItem)
    $('#myunipolapi').append(
    '<tr id="TT"><td id="TT">' + HeartbeatItem.pKey + '</td><td id="TT">' + HeartbeatItem.message + '</td><td id="TT">' + HeartbeatItem.password + '</td></tr>'
    );
    )

    );
    );



    Javascript ajax POST



    $('#searchButton').on('click',function() 
    $.ajax(
    type: 'POST',
    url: API_URL,
    data: JSON.stringify("search": $('#srch').val()),
    contentType: "application/json",

    success: function(data)
    $('#TT').load('#myunipolapi');

    );
    );


    Lambda



    console.log('starting function');
    const AWS = require('aws-sdk');
    const docClient = new AWS.DynamoDB.DocumentClient(region: 'eu-west-2');

    exports.handler = function(event, ctx, callback)

    console.log(event);

    var queryParams =
    TableName: 'Heartbeat',
    Key:
    "pKey": event.search

    ;

    docClient.get(queryParams, function(err, data)
    if(err)
    callback(err, null);
    else
    callback(null, data);

    );
    ;


    API




    "message": $input.json('$.message'),
    "password": $input.json('$.password'),
    "pKey": $input.json('$.pKey'),
    "search": $input.json('$.search')










    share|improve this question


























      1












      1








      1








      I am trying set up a search bar on my web-front that will allow the user to search for data in my dynamodb table using the key and then returns the results to the website.



      i tried to create an API POST function that that gives the value of the key that is being searched for to the lambda function. the resultant data from the lambda function is then presented on the web front via API GET.



      here is the relevant java script and html code and the relevant code from the lambda function.



      thank you very very much to those who chose to help i greatly appreciate it



      html



      <table id='table' style="width:50%">
      <thead>
      <tr>
      <th>pKey</th>
      <th>Message</th>
      <th>Password</th>
      </tr>
      </thead>
      <tbody id="myunipolapi">
      </tbody>
      </table>

      <form>
      <textarea id="srch" placeholder="Search Data"></textarea>
      </form>
      <div>
      <button id='searchButton'>Search</button>
      </div>

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>


      Javascript ajax GET



      $(document).ready(function()
      $.ajax(
      type: 'GET',
      url: API_URL,

      success: function(data)
      $('#myunipolapi').html('');

      data.Items.forEach(function(HeartbeatItem)
      $('#myunipolapi').append(
      '<tr id="TT"><td id="TT">' + HeartbeatItem.pKey + '</td><td id="TT">' + HeartbeatItem.message + '</td><td id="TT">' + HeartbeatItem.password + '</td></tr>'
      );
      )

      );
      );



      Javascript ajax POST



      $('#searchButton').on('click',function() 
      $.ajax(
      type: 'POST',
      url: API_URL,
      data: JSON.stringify("search": $('#srch').val()),
      contentType: "application/json",

      success: function(data)
      $('#TT').load('#myunipolapi');

      );
      );


      Lambda



      console.log('starting function');
      const AWS = require('aws-sdk');
      const docClient = new AWS.DynamoDB.DocumentClient(region: 'eu-west-2');

      exports.handler = function(event, ctx, callback)

      console.log(event);

      var queryParams =
      TableName: 'Heartbeat',
      Key:
      "pKey": event.search

      ;

      docClient.get(queryParams, function(err, data)
      if(err)
      callback(err, null);
      else
      callback(null, data);

      );
      ;


      API




      "message": $input.json('$.message'),
      "password": $input.json('$.password'),
      "pKey": $input.json('$.pKey'),
      "search": $input.json('$.search')










      share|improve this question
















      I am trying set up a search bar on my web-front that will allow the user to search for data in my dynamodb table using the key and then returns the results to the website.



      i tried to create an API POST function that that gives the value of the key that is being searched for to the lambda function. the resultant data from the lambda function is then presented on the web front via API GET.



      here is the relevant java script and html code and the relevant code from the lambda function.



      thank you very very much to those who chose to help i greatly appreciate it



      html



      <table id='table' style="width:50%">
      <thead>
      <tr>
      <th>pKey</th>
      <th>Message</th>
      <th>Password</th>
      </tr>
      </thead>
      <tbody id="myunipolapi">
      </tbody>
      </table>

      <form>
      <textarea id="srch" placeholder="Search Data"></textarea>
      </form>
      <div>
      <button id='searchButton'>Search</button>
      </div>

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>


      Javascript ajax GET



      $(document).ready(function()
      $.ajax(
      type: 'GET',
      url: API_URL,

      success: function(data)
      $('#myunipolapi').html('');

      data.Items.forEach(function(HeartbeatItem)
      $('#myunipolapi').append(
      '<tr id="TT"><td id="TT">' + HeartbeatItem.pKey + '</td><td id="TT">' + HeartbeatItem.message + '</td><td id="TT">' + HeartbeatItem.password + '</td></tr>'
      );
      )

      );
      );



      Javascript ajax POST



      $('#searchButton').on('click',function() 
      $.ajax(
      type: 'POST',
      url: API_URL,
      data: JSON.stringify("search": $('#srch').val()),
      contentType: "application/json",

      success: function(data)
      $('#TT').load('#myunipolapi');

      );
      );


      Lambda



      console.log('starting function');
      const AWS = require('aws-sdk');
      const docClient = new AWS.DynamoDB.DocumentClient(region: 'eu-west-2');

      exports.handler = function(event, ctx, callback)

      console.log(event);

      var queryParams =
      TableName: 'Heartbeat',
      Key:
      "pKey": event.search

      ;

      docClient.get(queryParams, function(err, data)
      if(err)
      callback(err, null);
      else
      callback(null, data);

      );
      ;


      API




      "message": $input.json('$.message'),
      "password": $input.json('$.password'),
      "pKey": $input.json('$.pKey'),
      "search": $input.json('$.search')







      javascript ajax api aws-lambda amazon-dynamodb






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited yesterday









      marc_s

      595k135 gold badges1139 silver badges1280 bronze badges




      595k135 gold badges1139 silver badges1280 bronze badges










      asked Mar 25 at 15:42









      Jason KonigJason Konig

      83 bronze badges




      83 bronze badges




















          1 Answer
          1






          active

          oldest

          votes


















          2














          Try that in your lambda:



           const dynamodb = new AWS.DynamoDB(apiVersion: '2012-08-10', region: 'eu-west-2');
          const params =
          ExpressionAttributeValues:
          ":key":
          S: event.search

          ,
          KeyConditionExpression: "pKey = :key",
          TableName: "Heartbeat"
          ;
          dynamodb.query(params, (err, data) =>
          if (err) console.log(err, err.stack); // an error occurred
          else console.log(data); // successful response
          );


          More info about NodeJS AWS-SDK: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html






          share|improve this answer























          • unfortunately it doesn't seem to work thank you any way though ... i think maybe the problem might lie in the javascript at the webfront or maybe how the data is sent to the lambda function because i have two buttons using the same format except different inputs will add a copy of the code i have in API if it is at all help full.

            – Jason Konig
            Mar 25 at 17:39










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55341506%2fhow-to-return-output-from-lambda-function-to-web-front-on-search-using-api%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          Try that in your lambda:



           const dynamodb = new AWS.DynamoDB(apiVersion: '2012-08-10', region: 'eu-west-2');
          const params =
          ExpressionAttributeValues:
          ":key":
          S: event.search

          ,
          KeyConditionExpression: "pKey = :key",
          TableName: "Heartbeat"
          ;
          dynamodb.query(params, (err, data) =>
          if (err) console.log(err, err.stack); // an error occurred
          else console.log(data); // successful response
          );


          More info about NodeJS AWS-SDK: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html






          share|improve this answer























          • unfortunately it doesn't seem to work thank you any way though ... i think maybe the problem might lie in the javascript at the webfront or maybe how the data is sent to the lambda function because i have two buttons using the same format except different inputs will add a copy of the code i have in API if it is at all help full.

            – Jason Konig
            Mar 25 at 17:39















          2














          Try that in your lambda:



           const dynamodb = new AWS.DynamoDB(apiVersion: '2012-08-10', region: 'eu-west-2');
          const params =
          ExpressionAttributeValues:
          ":key":
          S: event.search

          ,
          KeyConditionExpression: "pKey = :key",
          TableName: "Heartbeat"
          ;
          dynamodb.query(params, (err, data) =>
          if (err) console.log(err, err.stack); // an error occurred
          else console.log(data); // successful response
          );


          More info about NodeJS AWS-SDK: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html






          share|improve this answer























          • unfortunately it doesn't seem to work thank you any way though ... i think maybe the problem might lie in the javascript at the webfront or maybe how the data is sent to the lambda function because i have two buttons using the same format except different inputs will add a copy of the code i have in API if it is at all help full.

            – Jason Konig
            Mar 25 at 17:39













          2












          2








          2







          Try that in your lambda:



           const dynamodb = new AWS.DynamoDB(apiVersion: '2012-08-10', region: 'eu-west-2');
          const params =
          ExpressionAttributeValues:
          ":key":
          S: event.search

          ,
          KeyConditionExpression: "pKey = :key",
          TableName: "Heartbeat"
          ;
          dynamodb.query(params, (err, data) =>
          if (err) console.log(err, err.stack); // an error occurred
          else console.log(data); // successful response
          );


          More info about NodeJS AWS-SDK: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html






          share|improve this answer













          Try that in your lambda:



           const dynamodb = new AWS.DynamoDB(apiVersion: '2012-08-10', region: 'eu-west-2');
          const params =
          ExpressionAttributeValues:
          ":key":
          S: event.search

          ,
          KeyConditionExpression: "pKey = :key",
          TableName: "Heartbeat"
          ;
          dynamodb.query(params, (err, data) =>
          if (err) console.log(err, err.stack); // an error occurred
          else console.log(data); // successful response
          );


          More info about NodeJS AWS-SDK: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 25 at 15:57









          eL_FinitoeL_Finito

          2851 silver badge10 bronze badges




          2851 silver badge10 bronze badges












          • unfortunately it doesn't seem to work thank you any way though ... i think maybe the problem might lie in the javascript at the webfront or maybe how the data is sent to the lambda function because i have two buttons using the same format except different inputs will add a copy of the code i have in API if it is at all help full.

            – Jason Konig
            Mar 25 at 17:39

















          • unfortunately it doesn't seem to work thank you any way though ... i think maybe the problem might lie in the javascript at the webfront or maybe how the data is sent to the lambda function because i have two buttons using the same format except different inputs will add a copy of the code i have in API if it is at all help full.

            – Jason Konig
            Mar 25 at 17:39
















          unfortunately it doesn't seem to work thank you any way though ... i think maybe the problem might lie in the javascript at the webfront or maybe how the data is sent to the lambda function because i have two buttons using the same format except different inputs will add a copy of the code i have in API if it is at all help full.

          – Jason Konig
          Mar 25 at 17:39





          unfortunately it doesn't seem to work thank you any way though ... i think maybe the problem might lie in the javascript at the webfront or maybe how the data is sent to the lambda function because i have two buttons using the same format except different inputs will add a copy of the code i have in API if it is at all help full.

          – Jason Konig
          Mar 25 at 17:39






          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid …


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55341506%2fhow-to-return-output-from-lambda-function-to-web-front-on-search-using-api%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

          Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?