List All the Notes

From @jayair on Mon Apr 10 2017 01:06:19 GMT+0000 (UTC)

Link to chapter - http://serverless-stack.com/chapters/list-all-the-notes.html

Copied from original issue: https://github.com/AnomalyInnovations/serverless-stack-com/issues/51

From @nvallepalli on Fri Sep 22 2017 16:28:59 GMT+0000 (UTC)

cannot find the existing notes.

From @nvallepalli on Fri Sep 22 2017 16:33:47 GMT+0000 (UTC)

and also invoking create API works for creating notes. But, not able to create a note through the web app.
I mean I cannot find data in dynamodb table which I tried to insert using the web app.

From @jayair on Fri Sep 22 2017 21:01:00 GMT+0000 (UTC)

@nvallepalli So this chapter (https://serverless-stack.com/chapters/test-the-apis.html) worked for you. But you could not get it to work on the web? Can you check if the console is displaying any errors and if the request to create a note worked properly?

From @nvallepalli on Sat Sep 23 2017 02:03:16 GMT+0000 (UTC)

yeah this chapter (https://serverless-stack.com/chapters/test-the-apis.html) worked for me, but i could not get it on web.

From @jayair on Sun Sep 24 2017 01:29:10 GMT+0000 (UTC)

@nvallepalli Does the request to create the error succeed when you try it on the web?

I’m having some trouble, I don’t think it originates from the steps in this chapter but when I load the page to list all the notes I get a Status 500 error. Everything up to now has worked. I’ve been reading through these forums for a solution and often it’s suggested that with a 500 error you add a “console.log(e)” which I did in my get.js catch block. If that’s right, I cannot seem to find the log where it would give me more information. Is it in CloudWatch? Because there’s nothing obviously related there that I can find, just “status 500 body: false” messages. Frankly I’m really lost and I’m not sure what logs/error messages would be useful to post here.

I figured it out. It was a permissions problem at core, but it was massively confused by the fact that I was testing my GET method in the AWS API Gateway console. The problem with doing this is that in the GET method is the line “userId:event.requestContext.identity.cognitoIdentityId”, and of course the AWS API Gateway console has no cognito identity, or at least none corresponding to a table userId. The two-week’s headache is resolved and now I can die. Thanks for this tutorial, it’s great.

Hmm how come you were testing it through the API Gateway console?

I’m not sure I have a good answer for that. Generally I try to be familiar with the resources I’m working with. When I got the error I was digging around for any clues and I found that test console and figured I’d try it in order to get familiar, and because it might help me debug (I didn’t consider the fact that it might hurt my debugging).

1 Like

Yeah the debugging experience isn’t great.

1 Like

hello, I have the problem that after login the “isAuthenticated” flag is yet false at the Home Component, despite it is set to True in the Login component… I debugged and saw that calling userHasAuthenticated(true) has no effect (I print the props object right after that):

try {
  await Auth.signIn(fields.email, fields.password);
  console.log("setting props.userHasAuthenticated");
  props.userHasAuthenticated(true);
  console.log(props); <-- prints {... isAuthenticated: false,  ...}
} catch (e) {

edit 1: I learn that the useState hook is async, so that explains why it prints isAuthenticated: false in above snippet… but anyway, the change in that variable (if is happening) doesn’t fire the rendering of the list of notes in the home component (I always see the “lander” part). this is where I have the problem.

edit 2: Solved… I was yet using “props” instead of “appProps” in the route for the Home component:

  <AppliedRoute path="/" exact component={Home} appProps={appProps} />

Yup have a look at the recent changes. We now use React Context to pass them around.