Hi, I'm trying out the new SST. I'm trying to foll...
# help
j
Hi, I'm trying out the new SST. I'm trying to follow the guide in your page. I'm currently in https://serverless-stack.com/chapters/add-an-api-to-create-a-note.html. I have already deployed the changes and I'm now in the testing part. When I go to the SST console and press the send button, the send button changes to like a sending animation and then it goes back to 'send' again. When I check the DynamoDB console, no data was saved. Is there a log where I can check what's happening? or if there's an error somewhere? Hope you can help me out. Thank you!
m
hey @Jeff Cordova have you checked the local tab?
j
hi @manitej, i'm in the local tab right now and it just says Waiting for invocations...
r
If you set a debug breakpoint in your handler entry point, does it get hit? Or put a console log there
j
hi @Ross Coundon, I tried putting a console.log on after 'export async function main(event) {' line but it didn't show on my terminal nor on the console. I do get 500 error now and says Internal Server Error. Any tips on how I can debug this? Thank you!
r
Sounds like there could be a problem with the definition of the Function itself. Can you share your stack?
j
Sure, here's my git: https://github.com/jeffcordova/demo-notes-app. Thank you so much for taking time to check on this.
r
I don’t see any function definitions in the stack or handler code in there?
m
+1 @Ross Coundon, didn’t see any. @Jeff Cordova check your
.gitignore
j
Hi, kindly check again. I made a new push. Apologies for that.
r
I can’t tell from the repo but first thing I’d check is that the path to the function code is correct i.e. “POST /notes”: “functions/create.main”, For that there should be a
functions
folder in the root of the project with a file called
create
with a function called
main
inside it.
m
the
functions
folder should be inside
backend
folder. there’s no error over there.
@Jeff Cordova found your issue, you installed
aws-sdk uuid
at root. you should install them inside
backend/
folder. run
npm install aws-sdk uuid
inside
backend/
you can use this repo for reference: https://github.com/serverless-stack/demo-notes-app
j
Owwww...alright I'll check out that one. I'll update you guys in a bit. 🙂 Thank you!
r
@manitej - now I see the
Copy code
srcPath: "backend",
is set, I wondered how it referenced the backend folder.
m
yup, all the magic happens in the
stacks/index.js
😹
j
Hi, I removed the uuid and aws-sdk from the main folder and installed them in the backend folder but I still don't reach the api. I don't see the console.logs as well in my terminal. I tried looking at the repo that you sent @manitejbut the files there were already refactored so I can't really compare them yet. I pushed the new stack in git just in case you need to check them. Thank you.
m
can you run
sst remove
and restart again?
j
Hi @manitej, I did an
npx sst remove
then ran an
npx sst start
then got an error of
:x:  ServerlessStackAdmin-notes-StorageStack failed: ServerlessStackAdmin-notes-Notes already exists
. I'm guessing it wasn't able to delete the old stack? How do I remove the old stack?
I'll try this:
npx sst remove MyStack
m
it deleted the old stack but not the table
you can do 2 things now: 1. to rename the table name to something else 2. go to aws console and go to dynamodb page and search for table
ServerlessStackAdmin-notes-Notes
and delete it from the GUI and re run
sst start
j
got that! will do #2. thank you
Man! Did the trick! Thank you so much! Just want to ask, why I needed to do the remove? Is it some sort of cache? Every when should I do that?
m
my guess is that it has something to do with the bundling, so restarting might fix the issue.
j
Thank you @manitej and @Ross Coundon, I can now move on to my learning journey. 😀