From 77e069ae2763c878b33e801bcaf38cf3d7050289 Mon Sep 17 00:00:00 2001 From: cj Date: Thu, 10 Aug 2017 14:13:59 -0500 Subject: [PATCH] add component options to context --- lib/app/client.js | 6 ++++-- lib/app/server.js | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/app/client.js b/lib/app/client.js index 2cc5e637d7..5ed63fe2d4 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -33,7 +33,7 @@ NUXT.components = window.__COMPONENTS__ || null const defaultErrorHandler = Vue.config.errorHandler Vue.config.errorHandler = function (err, vm, info) { err.statusCode = err.statusCode || 'Whoops!' - + // Show Nuxt Error Page if(vm && vm.$root && vm.$root.$nuxt) { vm.$root.$nuxt.error(err) @@ -300,7 +300,9 @@ async function render (to, from, next) { // Call fetch(context) if (hasFetch) { - let p = Component.options.fetch(context) + let p = Component.options.fetch({ + ...context, options: Component.options + }) if (!p || (!(p instanceof Promise) && (typeof p.then !== 'function'))) { p = Promise.resolve(p) } diff --git a/lib/app/server.js b/lib/app/server.js index 11f011ea0b..c7f56f6a93 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -182,7 +182,9 @@ export default async context => { // Call fetch(context) if (Component.options.fetch) { - promises.push(Component.options.fetch(ctx)) + promises.push(Component.options.fetch({ + ...ctx, options: Component.options + })) } else { promises.push(null)