Async-data example working

This commit is contained in:
Sébastien Chopin 2016-11-07 14:12:59 +01:00
parent 59f69165bb
commit 3d206de7a5
4 changed files with 14 additions and 7 deletions

View File

@ -20,10 +20,11 @@ export default {
}
</script>
<style>
<style scoped>
p {
font-size: 20px;
text-align: center;
padding: 100px;
padding-bottom: 0;
}
</style>

View File

@ -10,17 +10,24 @@
const axios = require('axios')
export default {
async data ({ req }) {
const res = await axios.get('https://jsonplaceholder.typicode.com/posts/1')
return { post: res.data }
data ({ req }) {
return new Promise((resolve, reject) => {
axios.get('https://jsonplaceholder.typicode.com/posts/1')
.then((res) => {
resolve({
post: res.data
})
})
})
}
}
</script>
<style>
<style scoped>
p {
font-size: 20px;
text-align: center;
padding: 100px;
padding-bottom: 0;
}
</style>

View File

@ -208,7 +208,6 @@ function webpackWatchAndUpdate () {
const MFS = require('memory-fs') // <- dependencies of webpack
const mfs = new MFS()
const serverConfig = getWebpackServerConfig.call(this)
console.log(serverConfig)
const serverCompiler = webpack(serverConfig)
const outputPath = join(serverConfig.output.path, serverConfig.output.filename)
serverCompiler.outputFileSystem = mfs

View File

@ -1,6 +1,6 @@
{
"name": "nuxt",
"version": "0.1.2",
"version": "0.1.3",
"description": "A minimalistic framework for server-rendered Vue.js applications (inspired by Next.js)",
"main": "index.js",
"license": "MIT",