Add a Get Note API


#21

From @jayair on Sat Jan 27 2018 23:47:36 GMT+0000 (UTC)

@starkos That shouldn’t be the case for a GET request. Can you check your serverless.yml and ensure that method: get is set for this function?


#22

From @starkos on Mon Jan 29 2018 19:11:54 GMT+0000 (UTC)

Confirmed:

  get:
    handler: get.main
    events:
      - http:
          path: notes/{id}
          method: get
          cors: true
          authorizer: aws_iam

#23

From @jayair on Mon Jan 29 2018 19:52:51 GMT+0000 (UTC)

@starkos I see. This is weird. Which version of Serverless are you using?


#24

From @starkos on Mon Jan 29 2018 20:31:37 GMT+0000 (UTC)

1.25.0


#25

From @jayair on Wed Jan 31 2018 23:37:31 GMT+0000 (UTC)

@starkos Can you try it with the repo in the tutorial and see if you get the same thing? https://github.com/AnomalyInnovations/serverless-stack-demo-api/tree/add-a-get-note-api


#26

From @karthickng on Mon Mar 19 2018 11:30:45 GMT+0000 (UTC)

I faced a ResourceNotFoundException for a while trying to execute the code for this chapter.
Turned out, I needed to configure the AWS region again in get.js, despite issuing a create call earlier that was already doing this.

Can someone explain why this may be needed?


#27

From @jayair on Mon Mar 19 2018 18:13:53 GMT+0000 (UTC)

@karthickng Do you have multiple AWS credentials?


#28

From @smittym on Sun Apr 01 2018 13:20:52 GMT+0000 (UTC)

I had to do the same thing as karthickng and I do not have multiple AWS credentials.


#29

From @jayair on Mon Apr 02 2018 18:20:08 GMT+0000 (UTC)

@smittym @karthickng We moved the AWS.config.update({ region: "us-east-1" }); line inside src/libs/dynamodb-lib.js in the previous chapter. So just make sure it is in there for this chapter as well.


#30

@anomalyinnovations I had the same error as @starkos Serverless 1.27 adding “body”: “{“text”:”"}" fixed my issue.


#31

however - my response doesn’t show the ‘attachment’ field from the database instead shows the following:

{ "statusCode": 200, "headers": { "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Credentials": true }, "body": "{\"userId\":\"USER-SUB-1234\",\"docketId\":\"2d336b00-5ff9-11e8-a7dd-e1784f57d660\",\"createdAt\":1527238444464}" }


#32

Back in the Create API chapter, were you seeing the attachment?


#33

Yea, I was, though I ended up working out that I was calling the wrong function when invoking all good :slight_smile:


#34

I’m getting a serverless error

The file you provided does not exist.

any suggestions on what might be going wrong?


#35

Hmm I would just check the function names in the serverless.yml. And make sure your Lambda functions have the right file name.


#36

Does the serverless.yml get handler path parameter refer to the database name or the s3 bucket?

My create seems to be working fine, but get is having problems as is list.


#37

Can you compare it to this one from the tutorial?


#38

Mine is an exact match except for the region.


#39

followup question - where does aws_iam get it’s value from?


#40

I figured out my problem - it helps when the mock you are trying to call exists. I was calling get-event.json and the file was called get-event.js. Once that was fixed it worked fine.

Thank you for the help.