mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-06 13:03:11 +00:00
chore: minor improvements for server.js
This commit is contained in:
parent
ddc6369e05
commit
f635b73a0b
@ -85,8 +85,7 @@ export default async context => {
|
|||||||
if (typeof Component !== 'function' || Component.super === Vue) {
|
if (typeof Component !== 'function' || Component.super === Vue) {
|
||||||
return resolve(sanitizeComponent(Component))
|
return resolve(sanitizeComponent(Component))
|
||||||
}
|
}
|
||||||
const _resolve = (Component) => resolve(sanitizeComponent(Component))
|
return Component().then(Component => sanitizeComponent(Component))
|
||||||
Component().then(_resolve).catch(reject)
|
|
||||||
})))
|
})))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Throw back error to renderRoute()
|
// Throw back error to renderRoute()
|
||||||
@ -175,8 +174,8 @@ export default async context => {
|
|||||||
|
|
||||||
// Call asyncData(context)
|
// Call asyncData(context)
|
||||||
if (Component.options.asyncData && typeof Component.options.asyncData === 'function') {
|
if (Component.options.asyncData && typeof Component.options.asyncData === 'function') {
|
||||||
let promise = promisify(Component.options.asyncData.bind(_this), ctx)
|
const promise = promisify(Component.options.asyncData.bind(_this), ctx)
|
||||||
promise.then(asyncDataResult => {
|
.then(asyncDataResult => {
|
||||||
context.asyncData[Component.options.name] = asyncDataResult
|
context.asyncData[Component.options.name] = asyncDataResult
|
||||||
applyAsyncData(Component)
|
applyAsyncData(Component)
|
||||||
return asyncDataResult
|
return asyncDataResult
|
||||||
|
Loading…
Reference in New Issue
Block a user