Files
ghibli-api/pages/locations/_id.vue

33 lines
594 B
Vue

<template>
<div>
{{ location }}
</div>
</template>
<script>
import { mapState } from "vuex";
export default {
name: "Location",
head() {
return {
titleTemplate: `%s - ${this.location.name}`
};
},
validate({ params }) {
const uuid = new RegExp(
/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-4[0-9A-Za-z]{3}-[89ABab][0-9A-Za-z]{3}-[0-9A-Za-z]{12}$/
);
return uuid.test(params.id);
},
async asyncData({ params, store }) {
await store.dispatch("getLocation", params.id);
},
computed: {
...mapState(["location"])
}
};
</script>
<style></style>