Я программирую свое веб-приложение в React.( Not React Native )
Вчера это работало.Я пытался поиграться с import
заявлениями и версиями API.Теперь я получаю следующую ошибку:
Необработанный отказ (TypeError): _aws_amplify_core__WEBPACK_IMPORTED_MODULE_8 __. AWS.DynamoDB не является конструктором
import React, { Component } from 'react'
import { Route, Switch } from "react-router-dom";
import Amplify, { Auth } from 'aws-amplify';
import { AWS } from '@aws-amplify/core';
import { CognitoIdentityServiceProvider } from 'aws-sdk';
import PropTypes from 'prop-types'
import '../../stylesheets/Dashboard.css'
export default class Dynamo extends Component {
constructor(props) {
super(props)
this.state = {}
}
componentDidMount() {
Amplify.configure({
Auth: {
identityPoolId: identityPoolId,
region: region,
userPoolId: userPoolId,
userPoolWebClientId: userPoolWebClientId,
},
});
var context = this;
Auth.currentCredentials().then(credentials => {
// Constructor for the global config.
var AWSconfig = new AWS.Config({
apiVersion: '2016-04-18',
credentials: credentials,
region: 'us-XXXX-#'
});
console.log(credentials)
var dynamodb = new AWS.DynamoDB({
region: 'us-XXXX-#',
credentials: credentials
});
var params = {
Item: {
"email": {
S:`first.last@gmail.com`
},
"date": {
N: `${new Date()}`
},
"hours_worked": {
N: `5`
},
"note_approved": {
BOOL: (Math.random() < 0.5)
},
"note_written": {
BOOL: (Math.random() < 0.5)
},
"program": {
S: `*************************`
},
"total_miles": {
N: `${parseInt(Math.random() * 20 + 1)}`
}
},
ReturnConsumedCapacity: "TOTAL",
TableName: "Services"
};
dynamodb.putItem(params, function(err, data) {
if (err)
console.log(err, err.stack); // an error occurred
else {
console.log(data); // successful response
}
});
params = {
ExpressionAttributeNames:{
"#email": "email",
"#datetime_from": "date"
},
ExpressionAttributeValues: {
":e": {
S: "first.last@gmail.com"
},
":dearly": {
N: "1551500000000"
},
":dlate": {
N: "1551600000000"
}
},
KeyConditionExpression: "#email = :e and #datetime_from BETWEEN :dearly and :dlate",
TableName: "Services"
};
dynamodb.query(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else {
console.log(data); // successful response
context.setState({
records: data
})
}
});
});
}
render() {
return (
<div className='Dynamo'>
I AM RENDERING<br />
{this.state.records ? JSON.stringify(this.state.records) : null}
</div>
)
}
}
Dynamo.propTypes = {
}