I don't think it's a bug, local and prod creates 2...
# help
m
I don't think it's a bug, local and prod creates 2 different tables.
e
both my local and prod have data in the table I'm pulling from
m
I don't think so, can you show how are you passing the table name to the lambda?
I've confirmed that the dynamo db table is populated in both environments
m
yeah , the above code creates a different table for each stage.
e
and the GET /restaurants endpoint returns data in the SST console for local no problem
m
local and prod tables won't share the data
try to insert data into the prod table and do a GET request.
e
I did. the last screenshot in the thread is what I get and is my issue:
j
Did you confirm dynamodb has content? (directly in aws console)
e
yeah
a
can you show the lambda code?
often, when I had a problem with local working prod not working, it was because I forgot to wait for a promise resolution in the handler code
lambda will kill your handler even with outstanding promises if it reaches the end of the function
not sure if it will still return a 200 OK then, but might be
yeah, it won't kill your handler, but I guess you know what I mean
actually forget the whole thing, it can't really be your problem here, my cases usually had to do with external services not being called, not a response not containing the expected results
but seeing your code might still help
e
@Adrian Schweizer
a
looks pretty normal
can you log results and check it out in cloudwatch
just
console.log(results)
should work i think
maybe put another console log with a fixed string above it so you know its not just null or something
e
good suggestion to add console logging and checking cloud watch
I confirmed the prod stage Lambda is able to generate the response
however, this is what I get in the SST console...
very frustrating 😕
thanks for your assistance @Adrian Schweizer
finally got it working...
the response format from Lambda needs to be a certain way for API GW to return it
f
@Eric glad u figured it out. Did you get it to work by changing
data
to
body
in the response?
e
I just returned the
results.Items
from Dynamo DB and API GW set that return as the value for
body
j
@Eric just to clarify here, was the issue that the response you were seeing in the SST Console was from the Lambda function, as opposed to the API GW response?
e
@Jay, yeah...I think that ends up being the root cause. API GW expects a specific response format from the Lambda where the SST console does not. So my Lambda return format was working fine within the SST console but trying to get the response anywhere else didn't work since API GW wasn't processing the response correctly.
j
Yeah I can see that being confusing. Because the Console is showing it as if the API returned that response but it didn't really.
e
Agreed! Would be good to have some mention of that in the SST docs. Thanks for reaching out 🙂
a
Ah, damn, how could I miss the data attribute in your code...sorry about that.