Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentDidMount() {
// API Gateway
let apiName = 'MyAPIGatewayAPI';
let querypath = '/search/?scan=odcr';
// Loading
this.setState({ isLoading: true });
// Scan DynamoDB for results
API.get(apiName, querypath).then(response => {
this.setState({
instances: response,
isLoading: false
});
})
.then(response => {
console.log(this.state.instances)
})
.catch(error => {
this.setState({ error, isLoading: false })
console.log(error.response)
});
}
render() {
requestDispense: function() {
API.get("CDD_API", "/dispense", {
queryStringParameters: {
dispenserId: this.getDispenserId
},
responseType: "text"
})
.then(response => {
this.lastApiMessage = response;
console.log("Dispense command: ", response);
})
.catch(error => {
console.log(error);
});
}
},
fetchMenuList = async () => {
API.get('ReactSample','/items/restaurants/'+ sessionStorage.getItem('currentRestaurantId') + '/menu')
.then(data => {
console.log(data);
this.setState({
myTableData: data
});
return data;
})
.catch ( err => console.log(err))
}
componentDidMount() {
var self = this;
var path = ['/details',this.props.match.params.objectid].join('/');
var requestParams = {};
self.setState({
downloading: true
});
API.get('MediaAnalysisApi', path, requestParams)
.then(function(response) {
var filepath = ['media',response.object_id,'content',response.details.filename].join('/');
Storage.get(filepath,{level: 'private'})
.then(function(file) {
self.setState({
downloading: false,
media_file: file,
error_status: false
})
})
.catch(function(err) {
//console.log(err);
});
self.setState({
getPhrases() {
var self = this;
var phrases_path = ['/lookup',this.props.match.params.objectid,'phrases'].join('/');
var phrase_list = [];
API.get('MediaAnalysisApi', phrases_path, {})
.then(function(data) {
for (var p in data.Phrases) {
phrase_list.push({"Name":data.Phrases[p].Name, "Confidence":data.Phrases[p].Impressions[0].Score*100, "Id":[data.Phrases[p].Name.replace(/[^\w\s]|_/g, " ").replace(/\s+/g, " "),uuidv4()].join('-')});
}
self.setState({
"phrase_list": phrase_list
});
})
.catch(function(err) {
//console.log(err);
});
}
this.setState({ isLoading: true }, () => {
API.get(apiName, querypath).then(response => {
this.setState({ isLoading: false });
console.log('sent to sqs')
alert('Successful')
}).catch(error => {
console.log(error.response)
alert('Failed: ' + JSON.stringify(error.response.data))
});
});
}
listBooks() {
return API.get("books", `/books?category=${this.props.match.params.id}`, null);
}
getBook() {
return API.get("books", `/books/${this.props.bookId}`, null);
}
listOrdersInCart() {
return API.get("cart", "/cart", null);
}
getBook(order: Order) {
return API.get("books", `/books/${order.bookId}`, null);
}