Skip to content

Commit 3d206de

Browse files
author
Sébastien Chopin
committed
Async-data example working
1 parent 59f6916 commit 3d206de

4 files changed

Lines changed: 14 additions & 7 deletions

File tree

examples/async-data/pages/index.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ export default {
2020
}
2121
</script>
2222

23-
<style>
23+
<style scoped>
2424
p {
2525
font-size: 20px;
2626
text-align: center;
2727
padding: 100px;
28+
padding-bottom: 0;
2829
}
2930
</style>

examples/async-data/pages/post.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,24 @@
1010
const axios = require('axios')
1111
1212
export default {
13-
async data ({ req }) {
14-
const res = await axios.get('https://jsonplaceholder.typicode.com/posts/1')
15-
return { post: res.data }
13+
data ({ req }) {
14+
return new Promise((resolve, reject) => {
15+
axios.get('https://jsonplaceholder.typicode.com/posts/1')
16+
.then((res) => {
17+
resolve({
18+
post: res.data
19+
})
20+
})
21+
})
1622
}
1723
}
1824
</script>
1925

20-
<style>
26+
<style scoped>
2127
p {
2228
font-size: 20px;
2329
text-align: center;
2430
padding: 100px;
31+
padding-bottom: 0;
2532
}
2633
</style>

lib/build/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ function webpackWatchAndUpdate () {
208208
const MFS = require('memory-fs') // <- dependencies of webpack
209209
const mfs = new MFS()
210210
const serverConfig = getWebpackServerConfig.call(this)
211-
console.log(serverConfig)
212211
const serverCompiler = webpack(serverConfig)
213212
const outputPath = join(serverConfig.output.path, serverConfig.output.filename)
214213
serverCompiler.outputFileSystem = mfs

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nuxt",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "A minimalistic framework for server-rendered Vue.js applications (inspired by Next.js)",
55
"main": "index.js",
66
"license": "MIT",

0 commit comments

Comments
 (0)