- 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
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
<template>
<section class="container">
<Nav />
<Textarea />
</section>
</template>
<script>
import Nav from '~/components/Nav.vue'
import Textarea from '~/components/Textarea.vue'
import axios from 'axios'
export default {
components: {
Nav,
Textarea
},
/**
* We only need to fetch if the user is coming from a hard
* page load. if they were transferred here after creating a paste,
* the paste is already stored in the $store, no need to fetch.
* And we check if it's a hard reload by checking to see if
* there is a value for `state.content`.
*/
async fetch ({ store, params })
{
if (!store.state.content)
{
let id = params.id
let uri = `https://us-central1-tabbit-1313.cloudfunctions.net/get/?id=${params.id}`
try
{
let { data } = await axios.get(uri)
store.commit('UPDATE_ENTRIES', data.payload.paste)
store.commit('SET_ACTIVE_ENTRY', 0)
store.commit('SET_MODE', 'view')
store.commit('SET_CONTENT', data.payload.paste[0].content)
}
catch (e)
{
console.log(e)
console.log('-- ERR')
}
}
}
}
</script>
<style lang='stylus'>
body
height auto
textarea
overflow hidden
</style>