From 56099604eb307332e76ab4c75a58f3f201037319 Mon Sep 17 00:00:00 2001 From: srgooglo Date: Thu, 8 Jul 2021 13:24:43 +0200 Subject: [PATCH] fix get context --- src/client/index.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/client/index.js b/src/client/index.js index d02f691..9e9e67e 100644 --- a/src/client/index.js +++ b/src/client/index.js @@ -22,20 +22,21 @@ class Bridge { } function generateRouteDispatcher(bridge, method, route, getContext) { - return async function (body, query,...context){ + return async function (body, query, ...context){ let obj = Object() - - if (getContext === "function") { - context = {...context, getContext()} - } - - const response = await bridge.instance({ + let opt = { method: method, url: route, data: body, params: query, ...context - }) + } + + if (typeof getContext === "function") { + opt = {...opt, ...getContext()} + } + + const response = await bridge.instance(opt) obj = response.data obj.__proto__ = response