From 278033ee0a7e45243ebe2f7808eaa077eb5221f0 Mon Sep 17 00:00:00 2001 From: Akalanka Date: Thu, 8 Feb 2024 21:09:31 +0530 Subject: [PATCH] Fix(service-connector): async header interceptors --- packages/service-connector/src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/service-connector/src/index.js b/packages/service-connector/src/index.js index cd08154..0345605 100644 --- a/packages/service-connector/src/index.js +++ b/packages/service-connector/src/index.js @@ -8,7 +8,7 @@ import { formatLogs, coloredString } from "./helpers"; const serviceConnector = ({ service, headerIntercepts, loggable, logs = true, ...axiosOptions } = {}) => { const logger = moduleLogger(chalk.bold(service ?? "Service-Connector")); const instance = axios.create(axiosOptions); - instance.interceptors.request.use((config) => { + instance.interceptors.request.use(async (config) => { logs && logger.info( `Request initiated - ${coloredString("method")}: ${coloredString(config.method)} - ${coloredString( @@ -20,7 +20,7 @@ const serviceConnector = ({ service, headerIntercepts, loggable, logs = true, .. if (headerIntercepts) { config.headers = { ...config.headers, - ...headerIntercepts(config) + ...(await headerIntercepts(config)) }; } return config;