Skip to content

Instantly share code, notes, and snippets.

@Kaperskyguru
Last active July 20, 2020 12:56
Show Gist options
  • Save Kaperskyguru/186a1ee7361da920cba75f2f522eb6a3 to your computer and use it in GitHub Desktop.
Save Kaperskyguru/186a1ee7361da920cba75f2f522eb6a3 to your computer and use it in GitHub Desktop.
<script>
import { mapGetters } from "vuex";
import ErrorService from "../Services/ErrorService";
export default {
name: "HelloWorld",
props: {
todo: Object,
},
computed: {
...mapGetters(["getUser"]),
},
methods: {
getUserName(id) {
const user = this.getUser(id);
if (user) return user.username;
},
// Handling Errors in component
methodThrowsException() {
try {
// Do unexpected job
} catch (error) {
ErrorService.onError(error);
}
},
},
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment