如何使用 invokeApi 命令发送 queryStringParameters
How to send queryStringParameters with invokeApi command
带有查询字符串参数的端点的完整路径是:
https://api.mydomain.com/getData?param_01=value_01¶m_02=value_01
导入后 'aws-api-gateway-client'
var apigClientFactory = require('aws-api-gateway-client').default;
我继续配置变量:
let url = 'https://api.mydomain.com'
let pathTemplate = '/getData?param_01=value_01¶m_02=value_01';
let method = 'GET';
let params = '';
let additionalParams = '';
let body = '';
var client = apigClientFactory.newClient({
invokeUrl: url,
accessKey: 'my-accessKeyId',
secretKey: 'my-secretAccessKey',
sessionToken: 'my-sessionToken',
region: 'MY_AWS_REGION'
});
接下来调用端点:
client
.invokeApi(params, pathTemplate, method, additionalParams, body)
.then(function(res) {
console.log("...res:", res);
})
.catch(function(err) {
console.log("...err:", err);
});
但失败并出现错误
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
有没有办法用 invokeApi
命令发送 queryStringParameters?
let params = {};
let pathTemplate = '/getData';
let additionalParams = {
queryParams: {
param0: 'value0',
param1: 'value1'
}
};
带有查询字符串参数的端点的完整路径是:
https://api.mydomain.com/getData?param_01=value_01¶m_02=value_01
导入后 'aws-api-gateway-client'
var apigClientFactory = require('aws-api-gateway-client').default;
我继续配置变量:
let url = 'https://api.mydomain.com'
let pathTemplate = '/getData?param_01=value_01¶m_02=value_01';
let method = 'GET';
let params = '';
let additionalParams = '';
let body = '';
var client = apigClientFactory.newClient({
invokeUrl: url,
accessKey: 'my-accessKeyId',
secretKey: 'my-secretAccessKey',
sessionToken: 'my-sessionToken',
region: 'MY_AWS_REGION'
});
接下来调用端点:
client
.invokeApi(params, pathTemplate, method, additionalParams, body)
.then(function(res) {
console.log("...res:", res);
})
.catch(function(err) {
console.log("...err:", err);
});
但失败并出现错误
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
有没有办法用 invokeApi
命令发送 queryStringParameters?
let params = {};
let pathTemplate = '/getData';
let additionalParams = {
queryParams: {
param0: 'value0',
param1: 'value1'
}
};