Add a Create Note API


#101

By any chance do you have this line in libs/dynamodb-lib.js:

AWS.config.update({ region: "us-east-1" });


#102

ahh that fixed it!

changed the region on the config update,

thank you soo much!


Please fix this
#103

Thanks for helping out @justBanks


#104

That looks really strange. Which version of serverless are you using?


#105

@jayair I’ve been going through the tutorial. I want to ask about the URL path defined in the serverless.yml file. What does it do and is it necessary to have it the same as your database name? Thank you very much.


#106

Can you point me to the line that you are confused about?


#107

I have the same issue where I run either

serverless invoke local --function create --path mocks/create-event.json
serverless invoke local --function get --path mocks/get-event.json

both return nothing in terminal after I abstract w/ js files in libs dir

How were you able to get the 200 or 500 responses?


#108

same here after abstracting the responses and DB in the libs dir


#109

So it was working fine before you abstract stuff out?


#110

Hi

Thanks for the tutorial, everything was going smoothly until I hit this point.
I have the same problem as a couple people prior in that when I enter the following in the terminal:

serverless invoke local --function create --path mocks/create-event.json

I get back the command prompt with nothing else:

I have changed my region to ‘us-east-2’ in both places on my serverless.yml file.

Here are my config and credential files:
Config file: ~/.aws/config
[default]
region = us-east-2

Credentials: ~/.aws/credentials
aws_access_key_id=XXXXXXXX
aws_secret_access_key=XXXXXXX

When I enter ‘aws s3 ls’ in the terminal, I get back the proper name of my bucket
When I enter ‘aws dynamodb list-tables’, I get back: {“TableNames”: [“notes”]}

I"m not really sure what my next steps would be to troubleshoot this.
Any help would be appreciated.

Thanks.


#111

Oh. The region aspect seems good. Which version of Serverless are you using btw?


#112

It is the current one, as I had just installed it.
But I just figured out the problem…there were 2 issues:

  1. Serverless hadn’t installed properly due to permissions…simple chmod fixed that.
  2. I had the the create.js and ‘mocks’ folder in the wrong folder so just needed to move them.

Once I did that and re-ran the command, I was rewarded with a statusCode: 200.

Your one question regarding Serverless version in your response led me to the solution. Thanks for the help…I’m onto the next step.


#113

Awesome. I’ll keep that in mind when somebody else runs into this.


#114

I am sorry, I am new here and I am not a full-stack developer, but I want to learn. I had followed the tutorial until here, but in this step I get the following:

Serverless: INVOKING INVOKE
{
    "statusCode": 500,
    "headers": {
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Credentials": true
    },
    "body": "{\"status\":false}",
    "error": {
        "message": "The security token included in the request is invalid.",
        "code": "UnrecognizedClientException",
        "time": "2018-11-15T21:47:15.730Z",
        "requestId": "AIAJB0AVBFOBQJRHUF8FTIS70RVV4KQNSO5AEMVJF66Q9ASUAAJG",
        "statusCode": 400,
        "retryable": false,
        "retryDelay": 43.334367945545004
    }
}

Can someone to help me please?


#115

I had applied the refactoring of this step and the error now is the following:

Serverless: Bundling with Webpack...
Time: 864ms
Built at: 2018-11-15 16:30:05
        Asset      Size  Chunks             Chunk Names
    create.js  10.1 KiB  create  [emitted]  create
create.js.map  7.23 KiB  create  [emitted]  create
Entrypoint create = create.js create.js.map
[./create.js] 2.36 KiB {create} [built]
[./libs/dynamodb-lib.js] 468 bytes {create} [built]
[./libs/response-lib.js] 762 bytes {create} [built]
[aws-sdk] external "aws-sdk" 42 bytes {create} [built]
[babel-runtime/core-js/json/stringify] external "babel-runtime/core-js/json/stringify" 42 bytes {create} [built]
[babel-runtime/helpers/asyncToGenerator] external "babel-runtime/helpers/asyncToGenerator" 42 bytes {create} [built]
[babel-runtime/regenerator] external "babel-runtime/regenerator" 42 bytes {create} [built]
[source-map-support/register] external "source-map-support/register" 42 bytes {create} [built]
[uuid] external "uuid" 42 bytes {create} [built]
Serverless: INVOKING INVOKE
{ UnrecognizedClientException: The security token included in the request is invalid.
    at Request.extractError (E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\protocol\json.js:48:27)
    at Request.callListeners (E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\sequential_executor.js:106:20)
    at Request.emit (E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
    at Request.emit (E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\request.js:683:14)
    at Request.transition (E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\request.js:22:10)
    at AcceptorStateMachine.runTo (E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\state_machine.js:14:12)
    at E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\state_machine.js:26:10
    at Request.<anonymous> (E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\request.js:38:9)
    at Request.<anonymous> (E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\request.js:685:12)
    at Request.callListeners (E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\sequential_executor.js:116:18)
    at Request.emit (E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
    at Request.emit (E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\request.js:683:14)
    at Request.transition (E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\request.js:22:10)
    at AcceptorStateMachine.runTo (E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\state_machine.js:14:12)
    at E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\state_machine.js:26:10
    at Request.<anonymous> (E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\request.js:38:9)
    at Request.<anonymous> (E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\request.js:685:12)
    at Request.callListeners (E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\sequential_executor.js:116:18)
    at callNextListener (E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\sequential_executor.js:96:12)
    at IncomingMessage.onEnd (E:\Documentos Usuarios\DELGADOCJ\Desktop\Serverless\notes-app-api\node_modules\aws-sdk\lib\event_listeners.js:298:13)
    at IncomingMessage.emit (events.js:187:15)
    at IncomingMessage.EventEmitter.emit (domain.js:442:20)
    at endReadableNT (_stream_readable.js:1094:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  message: 'The security token included in the request is invalid.',
  code: 'UnrecognizedClientException',
  time: 2018-11-15T22:30:06.148Z,
  requestId: 'CKV6C8ARL1HJR7L8GQN2EORHORVV4KQNSO5AEMVJF66Q9ASUAAJG',
  statusCode: 400,
  retryable: false,
  retryDelay: 32.77251605004998 }
{
    "statusCode": 500,
    "headers": {
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Credentials": true
    },
    "body": "{\"status\":false}"
}

#116

I solved my problem. I made a mistake in a previous step with the command aws configure.

Thanks!