Add the Create Note Page


#1

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

Link to chapter - http://serverless-stack.com/chapters/add-the-create-note-page.html

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


#2

From @ScottMTravers on Tue May 02 2017 17:48:44 GMT+0000 (UTC)

I’m having an issue updating the disable attribute to ‘false’ on the ‘create’ button once I type in a few characters into the text field or upload a file. My NewNote.js is identical to the one in the tutorial. I’ve tried multiple times going through the tutorial steps after resetting to a past commit, but to no avail.

Here’s a couple screenshots (First - no text, Second - test note):



#3

From @jayair on Wed May 03 2017 00:28:58 GMT+0000 (UTC)

@ScottMTravers just to make sure, are there any errors that are showing up in the browser console? Also, what browser & OS combo are you on?


#4

From @ScottMTravers on Wed May 03 2017 00:52:02 GMT+0000 (UTC)

Using Chrome & Mac OSX 10.11.

Here’s the error showing up in my console:
Uncaught Error: addComponentAsRefTo(…): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component’s render method, or you have multiple copies of React loaded (details: https://fb.me/react-refs-must-have-owner).


#5

From @ScottMTravers on Wed May 03 2017 17:01:40 GMT+0000 (UTC)

Fixed the issue.

My notes-app-client was located inside the root directory of my notes-app-api instead of a separate project folder.


#6

From @jayair on Wed May 03 2017 19:41:49 GMT+0000 (UTC)

@ScottMTravers Oh! It’s a bit of a gotcha. We should make that clear when we start the frontend portion. Thanks for reporting back.


#7

From @walshe on Thu Mar 01 2018 18:12:27 GMT+0000 (UTC)

why does handleSubmit need event.preventDefault ? isnt it only a regular button action that needs this really ?


#8

From @jayair on Thu Mar 01 2018 20:52:21 GMT+0000 (UTC)

@walshe In this case it is a submit button. You could skip it. But if you had another field that you could “enter” to submit then you’ll need it.


#9

From @nuyulcore on Wed Mar 28 2018 13:01:12 GMT+0000 (UTC)



Hello, I got this error, when I try to post my notes.


#10

From @jayair on Wed Mar 28 2018 15:12:59 GMT+0000 (UTC)

@mbahfauz Are you logged in?


#11

Thanks so much for this amazing tutorial. I’m new to JavaScript and React and I’ve already learned a ton. Love your attention to detail and to getting a real-world example up and running as opposed to only creating toy projects.

I’d like to propose a small improvement for NewNote.js. I’d suggest replacing…

alert("Please pick a file smaller than 5MB");

with…

alert(`Please pick a file smaller than ${config.MAX_ATTACHMENT_SIZE/1000000} MB.`);

That way our maximum attachment size alert dialogue will directly represent the file size limit that’s been set in config.js. So if we decide to change it later, all we need to adjust is the MAX_ATTACHMENT_SIZE value in config.js.

Does that make sense?


#12

Ah good catch. Thanks for the heads up.


#13

Hi, I got stuck at the create note step.
When I submit the form I get this error in the console:

Failed to load https://xxx.execute-api.us-east-1.amazonaws.com/dev/notes: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3001' is therefore not allowed access. The response had HTTP status code 403.

If I inspect the request, I can see that the response is “Missing Authentication Token”.

I think the problem is that I don’t want authenticated users to save notes.
How can I make it so everyone can create a note, without being logged in?

Thanks!


#14

Answering your other thread.


#15

I’ve created the projects twice and reviewed every line of code many times over. However, I am constantly hitting a network error when trying to create the note in the react app. Creating through terminal works fine and Dynamo has my notes. When viewing the js console, it reports 3 403 errors (attached) but I can not find anything different in my code, other than calling it todo instead of note. All my yml functions have cors: true and the response-lib.js has the headers:

“Access-Control-Allow-Origin”: “*”,
“Access-Control-Allow-Credentials”: true

as specified. Can anyone help?


#16

Just replying here in case, have you added it to your Identity Pool IAM?

    {
      "Effect": "Allow",
      "Action": [
        "execute-api:Invoke"
      ],
      "Resource": [
        "arn:aws:execute-api:YOUR_API_GATEWAY_REGION:*:YOUR_API_GATEWAY_ID/*/*/*"
      ]
    }

Create Note Page 403
#17

Thanks for the reply, and love the tutorial and community! That helped track it down. I was focused on the code and not the policy. I had an extra character in the gateway ID.


#18

Glad you figure it out!


#19

Authenticated and Unauthenticated Routes. I’m assuming those are associated with the Authenticated and Unauthenticated Groups. My question is, is there a way to implement Groups within Cognito that are linked to routes directly or indirectly? Could this be something that goes into extra credit?


#20

Hmm this might be bad naming but they aren’t related. The routes we created are just for convenience. I’m not entirely sure if we can create ones that are linked somehow. I’d have to look into it.