AWS Amplify React Native,GET请求错误403状态代码

问题描述 投票:1回答:1

在集成身份验证之前,我启用了对未经身份验证的身份的访问以进行一些快速测试。我的配置代码如下,

Amplify.configure({
Auth: {
    identityPoolId: 'us-east-1:example',
    region: 'us-east-1',
    userPoolId: 'us-east-1_example',
    userPoolWebClientId: 'us-east-1_example'
},
API: {
    endpoints: [
        {
            name: "example-name",
            endpoint: "https://example.execute-api.us-east-1.amazonaws.com/prod/example-path"
        },
    ]
}
});

我的GET请求代码如下,

example() {
const apiName = 'example-name';
const path = '/example-path';

API.get(apiName, path).then(response => {
  console.log(response)
}).catch(error => {
  console.log(error)
})
}

我在GitHub和我的API网关上跟踪了所有内容,当我运行“测试”并通过邮递员时,Lambda函数正常工作。但是在本地反应时,它给了我403状态代码而没有任何详细的解释。这是否与使用未经身份验证的身份进行访问有关?此外,我在我的代码中使用“example”来隐藏我的个人信息,因为我没有收到任何语法错误,所以我输入正确的内容(每次运行时,身份池都会识别访问权限,但cloudWatch不显示任何日志网关访问)

amazon-web-services react-native aws-amplify
1个回答
1
投票

Amplify.configure中的端点是来自API网关的InvokeURL,您只需要包含舞台(本例中为/prod)而不包括其他路径。其他路由只是API。()调用的路径参数。

© www.soinside.com 2019 - 2024. All rights reserved.