I encountered a problem while using the JS SDK generated by API Gateway. Whenever there are errors, a CORS error occurs and I am unable to access the data or status code:
https://i.sstatic.net/9b4QT.png
Even though there is a message in the network tab, the data appears as ""
https://i.sstatic.net/d2ZnA.png
This is the code snippet I am working with:
AWS.config.region = "ap-northeast-2"
const cognitoParams = {
IdentityPoolId: "ap-northeast-2:...",
Logins: {
"accounts.google.com": googleUser.getAuthResponse().id_token
}
}
AWS.config.credentials = new AWS.CognitoIdentityCredentials(cognitoParams)
AWS.config.credentials.get(function () {
const api = apigClientFactory.newClient({
accessKey: AWS.config.credentials.accessKeyId,
secretKey: AWS.config.credentials.secretAccessKey,
sessionToken: AWS.config.credentials.sessionToken
})
api.ec2Get()
.then(function (data) {
console.log('data', data);
})
.catch(function (err) {
console.error('err', err)
})