Call the List API


#41

From @jayair on Mon Apr 23 2018 17:07:02 GMT+0000 (UTC)

@mbahfauz Sorry what didn’t work for you? Are you trying to call an API that doesn’t need authentication?


#42

From @nuyulcore on Mon Apr 23 2018 18:06:52 GMT+0000 (UTC)

@jayair Yap that is true bro. I want to call the note api for public who doesn’t need authentication.m


#43

From @jayair on Mon Apr 23 2018 18:41:28 GMT+0000 (UTC)

@mbahfauz You need to turn off authentication here - https://github.com/AnomalyInnovations/serverless-stack-demo-api/blob/master/serverless.yml#L73.

And you would need to pass in the user id for the notes you are fetching.


#44

From @nuyulcore on Mon Apr 23 2018 18:46:20 GMT+0000 (UTC)

Got it,
So the code would be like this?

list: # Defines an HTTP API endpoint that calls the main function in list.js # - path: url path is /notes # - method: GET request handler: list.main events: - http: path: notes method: get cors: true authorizer: turn_off

Or I should use other way?

Thanks


#45

From @jayair on Mon Apr 30 2018 18:16:13 GMT+0000 (UTC)

@mbahfauz You can just skip the authorizer option.


#46

notes() {
return API.get(“notes”, “/notes”);
}

The API.get() portion is failing with “Error: Network Error”. How can I troubleshoot this further / get a stack trace to determine what is happening? I’m on a Mac. aws-api-gateway-cli-test was successful and my API is deployed and working.


#47

Hmm that’s strange. I’m not sure about a stack trace in this case but did any other frontend API calls work for you?


#48

Hi jay,

Although this tutorial is pretty detailed and almost complete but one thing that I find missing is pagination at dynamoDB level as most of the modern day application are incomplete without pagination in today’s world.
Can we expect pagination in list API sometimes soon in this Serverless app architecture.

Thanks,
Bharat Chand


#49

Oh that’s a good point. Yeah I’ll add it to the list.


#50

Hi @jayair ,
I am making some modifications to your tutorial i have a list of projects with primary key their name. Is their a way to list on this part all the projects and not only the projects created by a user?
Thanks in advance


#51

Are you trying to get all the projects (or notes in our case) that are in the table?


#52

Hi. I am following your tutorial to create an application of my own. I had deploy the back end successfully and as far as I can tell the API.post function is working normally. But when I call API.get(), I’m having this error even though the serverless invoke local work nicely as well.
Access to XMLHttpRequest at ‘https://akhd9as2d6.execute-api.us-east-1.amazonaws.com/prod/funcs’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
Could you suggest where the error could be?
Thank you


#53

Hi Jay,

just wanted to check if pagination is in scope in the near future. tried myself but wasn’t successful.

Thanks,
Bharat Chand


#54

@iGrimJack Sometimes this error can really be unrelated to CORS. I would suggest checking out the API Gateway and Lambda logs. That might give you an idea of what is going on.

@19bharatvikram Yeah it is still on our list. If you are having problems with it, maybe we’ll try and put something out next week hopefully.