Skip to content

Commit 4a85e5d

Browse files
committed
Added pages/hello.vue, interfacing with lambda
1 parent 0820764 commit 4a85e5d

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

netlify.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Doc: https://www.netlify.com/docs/netlify-toml-reference/
12
[build]
2-
command = "yarn generate"
3+
command = "yarn build"
4+
functions = "lambdas-dist"
35
publish = "dist"

pages/hello.vue

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<template>
2+
<div>
3+
<h2>Hello, World!</h2>
4+
<b-btn variant="primary" @click="helloWorld()">Hello</b-btn>
5+
<p>Response: {{ response }}</p>
6+
<p v-if="error">
7+
<strong>Error {{ error.status }}</strong>
8+
<br />
9+
{{ error.data }}
10+
</p>
11+
</div>
12+
</template>
13+
14+
<script>
15+
export default {
16+
head() {
17+
return {
18+
title: 'Nuxt Netlify Lambda - Home',
19+
meta: [
20+
{
21+
hid: 'description',
22+
name: 'description',
23+
content: 'Nuxt Netlify Lambda Home description'
24+
}
25+
]
26+
}
27+
},
28+
data() {
29+
return {
30+
response: '',
31+
error: null
32+
}
33+
},
34+
methods: {
35+
async helloWorld() {
36+
try {
37+
const res = await this.$axios.$get('/.netlify/functions/hello')
38+
this.response = res
39+
this.error = null
40+
} catch (e) {
41+
this.error = e.response
42+
this.response = ''
43+
}
44+
}
45+
}
46+
}
47+
</script>

0 commit comments

Comments
 (0)