Request Failed with Error Code 502 in Call List API Chapter

#1

Hello All,
I have been going through the tutorial with some slight modifications but I am having trouble getting past this point. I have gone through the various posts that people have received for this issue but it always seems to come down to a typo in their serverless file or some URL. I have 2x, 3x, 4x checked everything to make sure but I am still receiving this error.

My Create API is working just fine and I am able to add new entries via my app. When I review the request I am receiving a Message stating that I am missing an Authentication Token and if I run my list mock file via the CLI I do get a response with all my “notes” but it fails within the App every time. From my research it seems like it may be due to my OPTIONS api method’s Authentication Method but I am unsure of what that needs to be set to. Any help is appreciated. Thank you.

Home.js:

    async componentDidMount() {
        if(!this.props.isAuthenticated) {
            return;
        }

        try {
            const items = await this.items();
            this.setState({ items });
        } catch(e) {
            alert(e);
        }

        this.setState({ isLoading: false });
    }

    items () {
        return API.get("SearchCriteria","/SearchCriteria");
    }

Serverless.yml:

list:
    handler: list.main
    events:
      - http:
          path: SearchCriteria
          method: get
          cors: true
          authorizer: aws_iam
#2

My typo was not on my list api but the update api. I had too many get functions in my serverless file and list was being overwritten. This is no longer an issue.

1 Like
#3

Glad you figure it out. Thanks for reporting back!