feat: pass headers to the ran request

This commit is contained in:
Andrew Bastin
2021-07-14 15:36:15 -04:00
parent 9ece8adda8
commit dcf34ea92c
2 changed files with 13 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
import { AxiosRequestConfig } from "axios"
import { BehaviorSubject, Observable } from "rxjs"
import AxiosStrategy, {
cancelRunningAxiosRequest,
@@ -20,7 +21,7 @@ export const cancelRunningRequest = () => {
const isExtensionsAllowed = () => settingsStore.value.EXTENSIONS_ENABLED
const runAppropriateStrategy = (req: any) => {
const runAppropriateStrategy = (req: AxiosRequestConfig) => {
if (isExtensionsAllowed() && hasExtensionInstalled()) {
return ExtensionStrategy(req)
}
@@ -52,10 +53,15 @@ export function createRESTNetworkRequestStream(
): Observable<HoppRESTResponse> {
const response = new BehaviorSubject<HoppRESTResponse>({ type: "loading" })
const headers = req.effectiveFinalHeaders.reduce((acc, { key, value }) => {
return Object.assign(acc, { [key]: value })
}, {})
const timeStart = Date.now()
runAppropriateStrategy({
url: req.effectiveFinalURL,
headers,
}).then((res: any) => {
const timeEnd = Date.now()