-
Notifications
You must be signed in to change notification settings - Fork 311
/
Copy pathApi.vue
50 lines (45 loc) · 1.08 KB
/
Api.vue
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
<template>
<div class="about">
<h1>Backend Resources Demo</h1>
<p>Click on the links below to fetch data from the Flask server</p>
<a href="" @click.prevent="fetchResource">Fetch</a><br/>
<a href="" @click.prevent="fetchSecureResource">Fetch Secure Resource</a>
<h4>Results</h4>
<p v-for="r in resources" :key="r.timestamp">
Server Timestamp: {{r.timestamp | formatTimestamp }}
</p>
<p>{{error}}</p>
</div>
</template>
<script>
import $backend from '../backend'
export default {
name: 'about',
data () {
return {
resources: [],
error: ''
}
},
methods: {
fetchResource () {
$backend.fetchResource()
.then(responseData => {
this.resources.push(responseData)
}).catch(error => {
this.error = error.message
})
},
fetchSecureResource () {
$backend.fetchSecureResource()
.then(responseData => {
this.resources.push(responseData)
}).catch(error => {
this.error = error.message
})
}
}
}
</script>
<style lang="scss">
</style>