How can I send data to aws lambda via aws gateway?

Y.Kim

I just started to study aws lambda & gateway and now I'm trying to make a simple API with aws Lambda.

This is my lambda function.

'use strict'
console.log('Loading event');

exports.handler = function(event, context, callback) {
var name = (event.name === undefined? 'No-Name' : event.name);
callback(null, {"Your-name" : name}); // SUCCESS with message
};

This is my mapping template.(Content-Type : application/json)

{"name" : "$input.params('name')"}

I want to change the value of name, so I tried,

var xhr = new XMLHttpRequest();
xhr.open('GET', 'my api url...');
xhr.onreadystatechange = function () {
   if (xhr.readyState === 4) {
       console.log(xhr.response);
   }
};
xhr.setRequestHeader("Content-Type", "application/json");
xhr.responseType = 'json';
var name = "JACK";
xhr.send(name);

It doesn't work. I want something like {"Your-name" : "JACK"} but it only returns {"Your-name" : "No-Name"}. How can I solve this problem?

Tom Melo

Did you try:

var json = JSON.stringify({ name: "JACK" });
xhr.send(json);

?

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Can I initiate a long-running AWS Lambda process via the Amazon API gateway asynchronously?

From Dev

How can I get a Lambda using AWS Gateway to return HTTP error status code in C#

From Dev

Return JSONP via AWS Lambda/API Gateway

From Dev

How can I create an AWS Lambda function using the AWS CLI?

From Dev

How do I debug AWS Api Gateway & Lambda's "AWS/ApiGateway 5XXError"

From Dev

How can I see AWS Gateway logs for external calls?

From Dev

How can I deny public access to an AWS API gateway?

From Java

Getting json body in aws Lambda via API gateway

From Dev

How can I get AWS Cognito login/logout to work properly with AWS API Gateway on Android?

From Dev

How to send chunks of data to AWS

From Dev

How to send chunks of data to AWS

From Dev

How to send http request with nodejs AWS Lambda?

From Dev

How can I improve the performance of an AWS Lambda Function with NodeJS?

From Dev

How to return net.socket data from AWS Lambda Node.js 8.10 async function to AWS API gateway?

From Dev

Can map custome domain to AWS Lambda Function without API Gateway

From Dev

AWS API gateway and LAMBDA Function

From Dev

AWS Gateway map path for lambda

From Dev

How can I retrieve a user's public IP address via Amazon API Gateway + Lambda (node)

From Dev

How can I send data to an API via the internet securely?

From Dev

How can I send fetching data from database via mail

From Dev

How can I send looped data via json?

From Dev

How to access HTTP headers for request to AWS API Gateway using Lambda?

From Dev

AWS: How to pass the resource defined in API gateway to lambda?

From Dev

How to trigger a ngrok get request in AWS API gateway and Lambda function?

From Java

Can I try out AWS Lambda locally without a AWS account?

From Dev

Calling AWS Lambda from browser using Javascript, how do I send input value to the function?

From Dev

Send an SMS via AWS SNS using boto3 in an AWS Lambda function?

From Java

How can I set the AWS API Gateway timeout higher than 30 seconds?

From Dev

How can I deny public access to an AWS API gateway while allowing access by only a specific role?

Related Related

  1. 1

    Can I initiate a long-running AWS Lambda process via the Amazon API gateway asynchronously?

  2. 2

    How can I get a Lambda using AWS Gateway to return HTTP error status code in C#

  3. 3

    Return JSONP via AWS Lambda/API Gateway

  4. 4

    How can I create an AWS Lambda function using the AWS CLI?

  5. 5

    How do I debug AWS Api Gateway & Lambda's "AWS/ApiGateway 5XXError"

  6. 6

    How can I see AWS Gateway logs for external calls?

  7. 7

    How can I deny public access to an AWS API gateway?

  8. 8

    Getting json body in aws Lambda via API gateway

  9. 9

    How can I get AWS Cognito login/logout to work properly with AWS API Gateway on Android?

  10. 10

    How to send chunks of data to AWS

  11. 11

    How to send chunks of data to AWS

  12. 12

    How to send http request with nodejs AWS Lambda?

  13. 13

    How can I improve the performance of an AWS Lambda Function with NodeJS?

  14. 14

    How to return net.socket data from AWS Lambda Node.js 8.10 async function to AWS API gateway?

  15. 15

    Can map custome domain to AWS Lambda Function without API Gateway

  16. 16

    AWS API gateway and LAMBDA Function

  17. 17

    AWS Gateway map path for lambda

  18. 18

    How can I retrieve a user's public IP address via Amazon API Gateway + Lambda (node)

  19. 19

    How can I send data to an API via the internet securely?

  20. 20

    How can I send fetching data from database via mail

  21. 21

    How can I send looped data via json?

  22. 22

    How to access HTTP headers for request to AWS API Gateway using Lambda?

  23. 23

    AWS: How to pass the resource defined in API gateway to lambda?

  24. 24

    How to trigger a ngrok get request in AWS API gateway and Lambda function?

  25. 25

    Can I try out AWS Lambda locally without a AWS account?

  26. 26

    Calling AWS Lambda from browser using Javascript, how do I send input value to the function?

  27. 27

    Send an SMS via AWS SNS using boto3 in an AWS Lambda function?

  28. 28

    How can I set the AWS API Gateway timeout higher than 30 seconds?

  29. 29

    How can I deny public access to an AWS API gateway while allowing access by only a specific role?

HotTag

Archive