Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async created() {
if (this.$store.getters.isAuth == true) {
// If created with valid authentication, read in user assets,
// read initial dispenser status then sub to MQTT topics
let response;
let authInfo;
let mqttResponse;
authInfo = await Auth.currentUserInfo();
response = await API.post("CDD_API", "/getResources", {
body: { cognitoIdentityId: authInfo.id }
});
console.log("resources response is ", response)
// Get resources needed to complete setup
await this.$store.dispatch("setAssets", response);
// Read dispenser shadow and credit status, and set
response = await API.get("CDD_API", "/status");
this.$store.dispatch("setStatus", response);
this.sub1
.subscribe([
"".concat("events/", this.$store.getters.dispenserId),
"".concat("$aws/things/", this.$store.getters.dispenserId, "/shadow/update/accepted")
])
.subscribe({
next: async () => {
// Use the event to trigger a getResources call
export const post = (hostname, route, params) => API.post(endpointName, route, params);
export const get = (hostname, route) => API.get(endpointName, route);
initRestaurant = async () => {
API.post('ReactSample','/items/init')
.then(data => {
alert('Successfully inserted restaurants');
this.setState({
data: data,
loading: false
});
})
.catch (err => console.log(err))
}
orderItem = async (restaurantId,itemId) => {
let requestParams = {
headers: {'content-type': 'application/json'},
body : {
'restaurant_id': restaurantId,
'menu_items': [{
'id':itemId,
'quantity': 1
}]
}
}
API.post('ReactSample','/items/orders', requestParams)
.then(data => {
sessionStorage.setItem('latestOrder', data.id);
console.log(data);
alert('Ordered successfully');
})
.catch (err => console.log(err))
}
function billUser(details) {
return API.post("notes", "/billing", {
body: details
});
}
return function(dispatch) {
dispatch({ type: CREATE_LIST_REQUEST })
AmplifyApi.post('checklist-api', '', {
body: {
name,
description
}
})
.then(result => {
dispatch({ type: CREATE_LIST_SUCCESS, payload: result })
})
.catch(err => {
dispatch({ type: CREATE_LIST_FAILURE, error: translateError(err) })
})
}
}
async apiSavePet(pet) {
return await API.post('Pets', '/items/pets', { body: pet });
}