<template>
  <div>
    <h1>Affichage du lien {{ link.url }}</h1>
  </div>
</template>

<script>
export default {
  async asyncData(context) {
    const link = await fetch(
      process.env.API_URL + "/api/links/" + context.params.id
    ).then(r => r.json());

    if (process.client) {
      return new Promise(resolve => {
        setTimeout(() => resolve({ link }), 5000);
      });
    }

    return { link };
  },
  head() {
    return {
      title: `Visualisation de ${this.link.url}`
    };
  }
};
</script>
