Sun Nov 18 2018
Copied to clipboard! Copy reply
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
import Nav from '~/components/Nav.vue'

  import axios from 'axios'

  export default {
    components: {
      Nav
    },

    data ()
    {
      return {
        pastes: []
      }
    },

    /**
     * Fetch the ids of pastes before rendering
     * the component
     */
    async asyncData({ params }) 
    {    
      let uri = `https://us-central1-tabbit-1313.cloudfunctions.net/recent`
      
      let { data } = await axios.get(uri)

      // Set state.pastes
      return { pastes: data.payload }
    }  
  }