1 Answer
- Newest
- Most votes
- Most comments
0
I managed to solve it by generating the api Gateway client. First step was to deploy my API in the Gateway portal. Second step is to go to the stages section, select the one where you deployed it and go to the SDK Generation tab, select your platform (in my case Javascript) and press the Generate SDK button.
Then I imported those things in my code.
<script type="text/javascript" src="lib/axios/dist/axios.standalone.js"></script>
<script type="text/javascript" src="lib/CryptoJS/rollups/hmac-sha256.js"></script>
<script type="text/javascript" src="lib/CryptoJS/rollups/sha256.js"></script>
<script type="text/javascript" src="lib/CryptoJS/components/hmac.js"></script>
<script type="text/javascript" src="lib/CryptoJS/components/enc-base64.js"></script>
<script type="text/javascript" src="lib/url-template/url-template.js"></script>
<script type="text/javascript" src="lib/apiGatewayCore/sigV4Client.js"></script>
<script type="text/javascript" src="lib/apiGatewayCore/apiGatewayClient.js"></script>
<script type="text/javascript" src="lib/apiGatewayCore/simpleHttpClient.js"></script>
<script type="text/javascript" src="lib/apiGatewayCore/utils.js"></script>
<script type="text/javascript" src="apigClient.js"></script>
You instantiate your api Client
apigClient = apigClientFactory.newClient({
accessKey: 'some access key',
secretKey: 'some secret key',
region: AWS.config.region
});
You use it like so:
var body = {};
var params = {
subscriber: email
}
var additionalParams = {}
apigClient.subscribersDevicesGet(params, body, additionalParams)
.then(function(result){
// clear form and show a success message
alert("Successful");
addSubscriberDevicesToForm(result.data.devices);
}).catch( function(result){
// show an error message
alert("Loading of devices failed: " + result);
});
where subscribersDevicesGet is my GET endpoint for /subscribers/devices endpoint
In the autocreated
apigClient.js
you have all of the endpoints defined
answered 4 years ago
Relevant content
- asked a year ago
- asked 3 months ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 2 months ago