mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-31 15:50:32 +00:00
Async-data example working
This commit is contained in:
parent
59f69165bb
commit
3d206de7a5
@ -20,10 +20,11 @@ export default {
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
<style scoped>
|
||||
p {
|
||||
font-size: 20px;
|
||||
text-align: center;
|
||||
padding: 100px;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
</style>
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user