in src/store/general/actions.js [147:187]
export function fetchGeoFenceItems(
{ commit }, { credentials }) {
try {
let locationList = [];
console.group("store/general/actions/fetchGeoFenceItems");
commit("SET_LOADER", true);
commit("SET_LOCATION_LIST", []);
let locationService = new Location({
credentials: credentials,
region: awsconfig.aws_project_region,
});
locationService.listGeofences({ CollectionName: process.env.VUE_APP_GEOFENCE }, function (err, response) {
if (err) console.log(err, err.stack); // an error occurred
else {
if (response && response.Entries.length > 0) {
for (let i = 0; i < response.Entries.length; i++) {
if (response.Entries[i].Status == "ACTIVE") {
locationList.push({
id: response.Entries[i].GeofenceId,
geoFenceName: response.Entries[i].GeofenceId,
boundary: response.Entries[i].Geometry.Polygon
})
}
}
}
}
});
//console.log(usersList);
commit("SET_LOCATION_LIST", locationList);
commit("SET_LOADER", false);
console.groupEnd();
} catch (error) {
console.error(error);
commit("SET_LOADER", false);
console.groupEnd();
throw error;
}
}