Cannot access event.queryStringParameters[ ... ][ ... ]
See original GitHub issueI believe i’m having issues with this topic as well… How do you access queryStringParameter?, if I remove the extra JSON argument in the call to API.get it works perfect! I’m just trying to figure out if this is indeed a problem with AWS amplify and how i’m sending the JSON parameter. Thank you in advance if you can push me in the correct direction.
My client side code (aws-amplify 0.2.11 ):
return API.get('trips','/days', {'queryStringParameters': {'param1': "99b60260-363c-11e8-b7ca-250a890d0675"}})
My API side code ( using serverless-webpack v 1.6.0, aws sdk v 2.202.0 ) : serverless.yml file :
listDays:
handler: listDays.main
events:
- http:
path: days
method: get
cors: true
authorizer: aws_iam
API-javascript listDays.js code trying to access the event, the event.queryStringParameter.param1 just causes an error because it’s null:
export async function main(event,context,callback) {
const params = {
TableName: "DAYS",
KeyConditionExpression: "tripId = :tripId",
ExpressionAttributeValues: {
":tripId": event.queryStringParameters.param1
}
}
//console.log(data.tripId)
try {
//result will return an array of trips
const result = await dynamoDbLib.call("query", params)
callback(null, success(result.Items))
} catch (e) {
callback(null, failure({status: false}))
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to correctly call queryStringParameters for AWS Lambda ...
I recommend adding a couple of diagnostics, as follows: import json def lambda_handler(event, context): print('event:', json.dumps(event)) ...
Read more >queryStringParameters not working with redirect on production
Given the redirect above, I would expect a GET to /thing to proxy a call to the netlify function URL, which would result...
Read more >API (REST) - Fetching data - JavaScript - AWS Amplify Docs
Using the GET API REST in Amplify - JavaScript - AWS Amplify Docs. ... queryStringParameters res.json({ event: req.apiGateway.event, // to view all event...
Read more >Accessing query parameter in Lambda with Python - Edureka
I am able to access body part using <Event> like <event['Number1']> but not able to access other request or header parameter . Have...
Read more >Set up Lambda proxy integrations in API Gateway
GET |POST|PUT|... /{proxy+} : The client can set a particular resource path hierarchy, any headers, query string parameters, and applicable payload to pass ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For any amature coder like myself: Because appending a JSON object queryStringParamaters is currently not implemented yet, Calling using AWS-amplify, on the client code side by appending to URL:
return API.get('trips',
/days?param1=${this.props.tripId})
API-side Node.js code: serverless yml file:
you access param1 by doing the following, also in the API-side Node.js code:
@HyperBrain I’ve never used
aws-amplify
too, but as you’ve mentioned, 1. It’s just an API URL call with query parameter and 2. it’s necessary to checkqueryStringParameters
before using it. Here is an example from aws docs.Also it looks like that
queryStringParameters
is not working inaws-amplify
: https://github.com/aws/aws-amplify/issues/127.And there is an opened PR about this issue: https://github.com/aws/aws-amplify/pull/378