I believe i’m having issues with API.get() . 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}))
}
}