(
path: string,
options: Options = {},
parser = (response: Response) => this.parseResponse(response),
)
| 242 | } |
| 243 | |
| 244 | async request( |
| 245 | path: string, |
| 246 | options: Options = {}, |
| 247 | parser = (response: Response) => this.parseResponse(response), |
| 248 | ) { |
| 249 | options = { cache: 'no-cache', ...options }; |
| 250 | const headers = await this.requestHeaders(options.headers || {}); |
| 251 | const url = this.urlFor(path, options); |
| 252 | let responseStatus = 500; |
| 253 | |
| 254 | try { |
| 255 | const req = unsentRequest.fromFetchArguments(url, { |
| 256 | ...options, |
| 257 | headers, |
| 258 | }) as unknown as ApiRequest; |
| 259 | const response = await requestWithBackoff(this, req); |
| 260 | responseStatus = response.status; |
| 261 | const parsedResponse = await parser(response); |
| 262 | return parsedResponse; |
| 263 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 264 | } catch (error: any) { |
| 265 | return this.handleRequestError(error, responseStatus); |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | nextUrlProcessor() { |
| 270 | return (url: string) => url; |
no test coverage detected