From c558f8402cbd7dd93755de376758f5c5fe02e627 Mon Sep 17 00:00:00 2001 From: maxswa Date: Sun, 28 May 2023 13:41:02 -0400 Subject: [PATCH] Add optional axios config arg to `httpGet` --- src/utils/helpers.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index 6c6174a..59f9c9a 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -1,4 +1,4 @@ -import axios from 'axios'; +import axios, { AxiosRequestConfig } from 'axios'; import * as ua from 'useragent-generator'; import { Gamemode, SkillName, ActivityName } from '../types'; import { @@ -96,12 +96,16 @@ export const rsnFromElement = (el: Element | null) => { * @param url URL to run a `GET` request against. * @returns Axios response. */ -export const httpGet = (url: string) => +export const httpGet = ( + url: string, + config: AxiosRequestConfig = {} +) => axios.get(url, { headers: { // without User-Agent header requests may be rejected by DDoS protection mechanism 'User-Agent': ua.firefox(80) - } + }, + ...config }); /**