mirror of
https://github.com/aelve/guide.git
synced 2024-12-23 21:02:13 +03:00
Fixed executing asyncData function on server on component resolving
This commit is contained in:
parent
65848205c9
commit
bd33eedf23
@ -1,11 +1,14 @@
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const moment = require('moment')
|
const moment = require('moment')
|
||||||
|
const axios = require('axios')
|
||||||
|
|
||||||
const appName = 'Aelve Guide'
|
const appName = 'Aelve Guide'
|
||||||
const clientPort = 4000
|
const clientPort = 4000
|
||||||
const ssrPort = 5000
|
const ssrPort = 5000
|
||||||
const distPath = rootResolve('./dist')
|
const distPath = rootResolve('./dist')
|
||||||
|
|
||||||
|
axios.defaults.baseURL = `http://localhost:${ssrPort}`
|
||||||
|
|
||||||
const env = {
|
const env = {
|
||||||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
||||||
'process.env.BUILD_TIME': JSON.stringify(moment(new Date()).format('YYYY-MM-DD HH:mm:ss'))
|
'process.env.BUILD_TIME': JSON.stringify(moment(new Date()).format('YYYY-MM-DD HH:mm:ss'))
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'reflect-metadata'
|
import 'reflect-metadata'
|
||||||
|
import _get from 'lodash/get'
|
||||||
import { createApp } from './app'
|
import { createApp } from './app'
|
||||||
|
|
||||||
export default context => {
|
export default context => {
|
||||||
@ -18,7 +19,9 @@ export default context => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Promise.all(matchedComponents.map((Component) => {
|
Promise.all(matchedComponents.map((Component) => {
|
||||||
const asyncDataFunc = Component['asyncData'] || (Component['options'] || {})['asyncData']
|
const asyncDataFunc = Component['asyncData']
|
||||||
|
|| _get(Component, 'options.asyncData')
|
||||||
|
|| _get(Component, 'options.methods.asyncData')
|
||||||
if (typeof asyncDataFunc === 'function') {
|
if (typeof asyncDataFunc === 'function') {
|
||||||
return asyncDataFunc({
|
return asyncDataFunc({
|
||||||
store,
|
store,
|
||||||
|
Loading…
Reference in New Issue
Block a user