# Add a Create Note API

**URL:** <https://discourse.sst.dev/t/add-a-create-note-api/125>\
**Category:** Chapter Comments\
**Created:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125 "2018-05-09T19:44:26Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/21 "2018-05-09T19:44:37Z")

</div>

_From @martinsaporiti on Sun May 21 2017 11:50:29 GMT+0000 (UTC)_  
  
Hi, everyone. I need your help, please!!!

When I running _serverless webpack invoke --function create --path event.json_ the result is this:

```bash
	**import _JSON$stringify from 'babel-runtime/core-js/json/stringify';**
	^^^^^^
SyntaxError: Unexpected token import
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at ServerlessWebpack.loadHandler (/Users/sapo/Development/notes/notes-app-api/node_modules/serverless-webpack/lib/run.js:21:20)
    at ServerlessWebpack.run (/Users/sapo/Development/notes/notes-app-api/node_modules/serverless-webpack/lib/run.js:61:26)
    at ServerlessWebpack.tryCatcher (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:693:18)
    at Promise._fulfill (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:638:18)
    at Promise._resolveCallback (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:432:57)
    at Promise._settlePromiseFromHandler (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:524:17)
    at Promise._settlePromise (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:693:18)
    at Promise._fulfill (/Users/sapo/Development/notes/notes-app-api/node_modules/bluebird/js/release/promise.js:638:18)
From previous event:
    at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:234:22)
    at PluginManager.run (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:253:17)
    at variables.populateService.then (/usr/local/lib/node_modules/serverless/lib/Serverless.js:96:33)
From previous event:
    at Serverless.run (/usr/local/lib/node_modules/serverless/lib/Serverless.js:87:74)
    at serverless.init.then (/usr/local/lib/node_modules/serverless/bin/serverless:23:50)

  Your Environment Information -----------------------------
     OS: darwin
     Node Version: 6.9.4
     Serverless Version: 1.13.2

```

Thanks!!!

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/22 "2018-05-09T19:44:37Z")

</div>

_From @jayair on Sun May 21 2017 19:07:48 GMT+0000 (UTC)_  
  
@go4cas That’s weird, the `react-app` preset should handle that already. Can I see your `package.json` just to make sure things are okay?

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/23 "2018-05-09T19:44:37Z")

</div>

_From @jayair on Sun May 21 2017 19:09:10 GMT+0000 (UTC)_  
  
@martinsaporiti this looks like the same issue as @go4cas. Let me check what is going on.

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/24 "2018-05-09T19:44:37Z")

</div>

_From @jayair on Sun May 21 2017 20:19:33 GMT+0000 (UTC)_  
  
@martinsaporiti @go4cas You guys are right, there is an issue with the new `react-app` preset. I just updated the chapter with the proper presets - [https://github.com/AnomalyInnovations/serverless-stack-com/commit/201c8818686650b67008d108b0aef047d8a59cec](https://github.com/AnomalyInnovations/serverless-stack-com/commit/201c8818686650b67008d108b0aef047d8a59cec)

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/25 "2018-05-09T19:44:38Z")

</div>

_From @martinsaporiti on Mon May 22 2017 02:15:26 GMT+0000 (UTC)_  
  
Thanks @jayair and @go4cas ! Now work perfectly:

```auto
{ statusCode: 200,
  headers: 
   { 'Access-Control-Allow-Origin': '*',
     'Access-Control-Allow-Credentials': true },
  body: '{"userId":"USER-SUB-1234","noteId":"b605af70-3e93-11e7-8117-312305557adf","content":"hello world","attachment":"hello.jpg","createdAt":1495418979303}' }

```

I will continue with the tutorial. It’s very useful.  
Thanks again!

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/26 "2018-05-09T19:44:38Z")

</div>

_From @oliv9286 on Fri Jun 02 2017 21:01:20 GMT+0000 (UTC)_  
  
@jayair I’m running into the same problem as @deivers and @vfonsecapv when I run the test with event.json. I do have multiple profiles and I’m not using the default profile in this case. I’m using us-west-2 and I believe I already changed that everywhere in the code. Any clue how I can debug?

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/27 "2018-05-09T19:44:38Z")

</div>

_From @oliv9286 on Fri Jun 02 2017 21:23:14 GMT+0000 (UTC)_  
  
nevermind, I figured it out. If you’re not using your default profile then in your create.js you need to do  
`const credentials = new AWS.SharedIniFileCredentials({profile: 'profile_name'}); AWS.config.credentials = credentials;`

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/28 "2018-05-09T19:44:39Z")

</div>

_From @jayair on Sat Jun 03 2017 11:46:36 GMT+0000 (UTC)_  
  
@oliv9286 Thanks for reporting back. Are you setting this in the top of your `create.js`?

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/29 "2018-05-09T19:44:39Z")

</div>

_From @tobyjo on Mon Jun 05 2017 15:27:48 GMT+0000 (UTC)_  
  
I also get the same error as @deivers and @vfonsecapv .

When I run

```auto
./node_modules/serverless/bin/serverless webpack invoke --function create --path event.json

```

I get

```auto
Serverless: Run function create...
{ ResourceNotFoundException: Requested resource not found
    at Request.extractError (/home/tjones/note-app-api/node_modules/aws-sdk/lib/protocol/json.js:48:27)
    at Request.callListeners (/home/tjones/note-app-api/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (/home/tjones/note-app-api/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/home/tjones/note-app-api/node_modules/aws-sdk/lib/request.js:682:14)
    at Request.transition (/home/tjones/note-app-api/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/home/tjones/note-app-api/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /home/tjones/note-app-api/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/home/tjones/note-app-api/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/home/tjones/note-app-api/node_modules/aws-sdk/lib/request.js:684:12)
    at Request.callListeners (/home/tjones/note-app-api/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
    at Request.emit (/home/tjones/note-app-api/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/home/tjones/note-app-api/node_modules/aws-sdk/lib/request.js:682:14)
    at Request.transition (/home/tjones/note-app-api/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/home/tjones/note-app-api/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /home/tjones/note-app-api/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/home/tjones/note-app-api/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/home/tjones/note-app-api/node_modules/aws-sdk/lib/request.js:684:12)
    at Request.callListeners (/home/tjones/note-app-api/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
    at callNextListener (/home/tjones/note-app-api/node_modules/aws-sdk/lib/sequential_executor.js:95:12)
    at IncomingMessage.onEnd (/home/tjones/note-app-api/node_modules/aws-sdk/lib/event_listeners.js:256:13)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
  message: 'Requested resource not found',
  code: 'ResourceNotFoundException',

```

Note that I didnt install the serverless module as global.  
I do not have multiple profiles as @oliv9286 did.

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/30 "2018-05-09T19:44:39Z")

</div>

_From @fwang on Wed Jun 07 2017 15:35:18 GMT+0000 (UTC)_  
  
@tobyjo can I take a look at your serverless.yml?

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/31 "2018-05-09T19:44:40Z")

</div>

_From @tobyjo on Thu Jun 08 2017 09:27:53 GMT+0000 (UTC)_  
  
@fwang Sure, please find attached.  
[serverless.zip](https://github.com/AnomalyInnovations/serverless-stack-com/files/1060530/serverless.zip)

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/32 "2018-05-09T19:44:40Z")

</div>

_From @kevinnguy on Sat Jun 10 2017 05:56:13 GMT+0000 (UTC)_  
  
@tobyjo I’ve had the same issue as you and my problem was that my DynamoDB table wasn’t created when I thought I did. I would double-check in your AWS Console and see if your `notes` table was created.

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/33 "2018-05-09T19:44:40Z")

</div>

_From @fwang on Sat Jun 10 2017 15:12:04 GMT+0000 (UTC)_  
  
@tobyjo A side note about your serverless.yml, this is not related to the error you are seeing. The authorizer arn in your serverless.yml should start with “arn:aws:cognito-idp:” and look something like " arn:aws:cognito-idp:us-east-1:232771856781:userpool/us-east-1\_YExxXXxxx". You can get the User Pool arn from this chapter:

> **[Create a Cognito User Pool](https://serverless-stack.com/chapters/create-a-cognito-user-pool.html)**
>
> Amazon Cognito User Pool handles sign-up and sign-in functionality for web and mobile apps. We are going to create a Cognito User Pool to store and manage the users for our serverless app. We’ll use the email address as username option since we want...

Back to the issue you were seeing, try @kevinnguy’s suggestion.

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/34 "2018-05-09T19:44:40Z")

</div>

_From @tobyjo on Fri Jun 16 2017 13:51:30 GMT+0000 (UTC)_  
  
@kevinnguy @fwang Thanks both. Have been distracted currently with other work but as soon as I get back to this I will let you know the results. Thanks again.

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/35 "2018-05-09T19:44:41Z")

</div>

_From @copperspeed on Fri Jun 23 2017 07:53:35 GMT+0000 (UTC)_  
  
Any reason why I am receiving the error below?

```auto
serverless webpack invoke -f create -p mocks/create-event.json
/mnt/c/Users/cgrecea/AppData/Roaming/npm/node_modules/serverless/node_modules/bluebird/js/release/async.js:48
        fn = function () { throw arg; };
                           ^

ServerlessError: In the command you just typed, the "webpack" is valid but "invoke" is not. Enter "serverless help" to see the actions for this context.
    at new ServerlessError (/mnt/c/Users/cgrecea/AppData/Roaming/npm/node_modules/serverless/lib/ServerlessError.js:17:11)

```

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/36 "2018-05-09T19:44:41Z")

</div>

_From @jayair on Fri Jun 23 2017 17:11:22 GMT+0000 (UTC)_  
  
@copperspeed Can you make sure you’ve added `serverless-webpack` to your project? We do this in the **Install Babel and Webpack** step of this chapter [http://serverless-stack.com/chapters/add-support-for-es6-es7-javascript.html](http://serverless-stack.com/chapters/add-support-for-es6-es7-javascript.html).

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/37 "2018-05-09T19:44:41Z")

</div>

_From @copperspeed on Sat Jun 24 2017 01:33:26 GMT+0000 (UTC)_  
  
@jayair yes, I have serverless-webpack installed.

```auto
devDependencies": {
    "aws-sdk": "^2.72.0",
    "babel-core": "^6.25.0",
    "babel-loader": "^7.0.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-3": "^6.24.1",
    "glob": "^7.1.2",
    "serverless-webpack": "^1.0.0-rc.4",
    "webpack": "^2.6.1",
    "webpack-node-externals": "^1.6.0"
  },
  "dependencies": {
    "babel-runtime": "^6.23.0",
    "uuid": "^3.1.0"
  }

```

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/38 "2018-05-09T19:44:42Z")

</div>

_From @copperspeed on Sat Jun 24 2017 21:58:33 GMT+0000 (UTC)_  
  
Ok, my issue was do to forgetting to install Serverless. Duh!!! lol

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/39 "2018-05-09T19:44:42Z")

</div>

_From @RobbingDaHood on Tue Jul 04 2017 17:11:49 GMT+0000 (UTC)_  
  
This weekend I got through the whole example without any problems, today I get the error:

ERROR in Entry module not found: Error: Can’t resolve ‘babel’ in ‘C:\projects\happyToHelp\backend’  
BREAKING CHANGE: It’s no longer allowed to omit the ‘-loader’ suffix when using loaders.  
You need to specify ‘babel-loader’ instead of ‘babel’,  
see [https://webpack.js.org/guides/migrating/#automatic-loader-module-name-extension-removed](https://webpack.js.org/guides/migrating/#automatic-loader-module-name-extension-removed)

When executing:  
serverless webpack invoke --function create --path mocks/create-event.json

I fixed this by going to webpack.config.js and changing from:  
loaders: [‘babel’],  
To:  
loaders: [‘babel-loader’],

And now it works.

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 7:44pm UTC](https://discourse.sst.dev/t/add-a-create-note-api/125/40 "2018-05-09T19:44:42Z")

</div>

_From @jayair on Tue Jul 04 2017 17:27:08 GMT+0000 (UTC)_  
  
@RobbingDaHood Thanks for letting us know. I’ll take a look into whats going on. Can you share your `package.json`? I’d like to see which version is giving this error.

[Previous page](https://discourse.sst.dev/t/add-a-create-note-api/125.md?page=1)

[Next page](https://discourse.sst.dev/t/add-a-create-note-api/125.md?page=3)
