Skip to content

Commit 3cd8478

Browse files
authored
feat: add axios option for nuxt
Add axios options for fetching data with Nuxt asyncData hook and Fetch hook
1 parent 00f7c97 commit 3cd8478

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

snippets/nuxt-script.json

+19
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99
],
1010
"description": "Nuxt asyncData"
1111
},
12+
"Nuxt Async": {
13+
"prefix": "nasyncdataaxios",
14+
"body": [
15+
"async asyncData ({ ${1:$axios}, { ${2:params} }) {",
16+
"\tconst data = await $axios.$get(`${3:endpoint/${params.slug}}`)",
17+
"\treturn { data }",
18+
"},"
19+
],
20+
"description": "Nuxt asyncData with Axios module"
21+
},
1222
"Nuxt Fetch": {
1323
"prefix": "nfetch",
1424
"body": [
@@ -19,6 +29,15 @@
1929
],
2030
"description": "Nuxt Fetch"
2131
},
32+
"Nuxt Fetch with Axios": {
33+
"prefix": "nfetchaxios",
34+
"body": [
35+
"async fetch () {",
36+
"\tlet this.data = await this.$axios.$get('${1:endpoint/${this.$route.params.slug}}')",
37+
"},"
38+
],
39+
"description": "Nuxt Fetch with Axios module"
40+
},
2241
"Nuxt Route Params": {
2342
"prefix": "nparam",
2443
"body": ["this.$route.params.${1:id}"],

0 commit comments

Comments
 (0)