<template>
  <div>
    {{ film }}
  </div>
</template>

<script>
export default {
  name: "Film",
  head() {
    return {
      titleTemplate: `%s - ${this.film.title}`
    };
  },
  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({ $axios, params }) {
    const film = await $axios.$get(`/api/films/${params.id}`);
    return { film };
  },
  data() {
    return {
      film: {}
    };
  }
};
</script>

<style></style>
