带有查询参数 returns 的 GET 请求 403 错误(签名不匹配)- AWS Amplify
GET request with query parameters returns 403 error (signature does not match) - AWS Amplify
问题
我试图在客户端使用 'aws-amplify' GET API 请求 和查询参数 ,但结果是 请求失败,状态码为403,响应显示:
"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
注:React.js为前端,Javascript为后端。
我的代码
前端
function getData() {
const apiName = 'MyApiName';
const path = '/path';
const content = {
body:{
data:'myData',
},
};
return API.get(apiName, path, content);
}
后端
try {
const result = await dynamoDbLib.call("query", params);
} catch (e) {
return failure({ status: false });
}
我调试了什么
- GET lambda 函数在 Amazon 控制台中运行良好(已测试)
- 如果我更改后端 lambda 函数以便可以在没有参数的情况下发出前端请求,即
return API.get(apiName, path)
,则不会出现错误。
我的问题
如何使这个带有查询参数的 GET 请求 有效?
我将 GET 更改为 POST (return API.post()
),现在一切正常。
如果有人能提供更详细的解释,那将非常有帮助。
问题
我试图在客户端使用 'aws-amplify' GET API 请求 和查询参数 ,但结果是 请求失败,状态码为403,响应显示:
"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
注:React.js为前端,Javascript为后端。
我的代码
前端function getData() {
const apiName = 'MyApiName';
const path = '/path';
const content = {
body:{
data:'myData',
},
};
return API.get(apiName, path, content);
}
后端
try {
const result = await dynamoDbLib.call("query", params);
} catch (e) {
return failure({ status: false });
}
我调试了什么
- GET lambda 函数在 Amazon 控制台中运行良好(已测试)
- 如果我更改后端 lambda 函数以便可以在没有参数的情况下发出前端请求,即
return API.get(apiName, path)
,则不会出现错误。
我的问题
如何使这个带有查询参数的 GET 请求 有效?
我将 GET 更改为 POST (return API.post()
),现在一切正常。
如果有人能提供更详细的解释,那将非常有帮助。