Add a Get Note API


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?


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


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


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?


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



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?


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?


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

@karthickng Do you have multiple AWS credentials?


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.


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.


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


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}" }


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


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


I’m getting a serverless error

The file you provided does not exist.

any suggestions on what might be going wrong?


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


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.


Can you compare it to this one from the tutorial?


Mine is an exact match except for the region.


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


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.