(
path: string,
options: Options = {},
parser = (response: Response) => this.parseResponse(response),
)
| 216 | } |
| 217 | |
| 218 | async request( |
| 219 | path: string, |
| 220 | options: Options = {}, |
| 221 | parser = (response: Response) => this.parseResponse(response), |
| 222 | ) { |
| 223 | options = { cache: 'no-cache', ...options }; |
| 224 | const headers = await this.requestHeaders(options.headers || {}); |
| 225 | const url = this.urlFor(path, options); |
| 226 | let responseStatus = 500; |
| 227 | |
| 228 | try { |
| 229 | const req = unsentRequest.fromFetchArguments(url, { |
| 230 | ...options, |
| 231 | headers, |
| 232 | }) as unknown as ApiRequest; |
| 233 | const response = await requestWithBackoff(this, req); |
| 234 | responseStatus = response.status; |
| 235 | const parsedResponse = await parser(response); |
| 236 | return parsedResponse; |
| 237 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 238 | } catch (error: any) { |
| 239 | return this.handleRequestError(error, responseStatus); |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | nextUrlProcessor() { |
| 244 | return (url: string) => url; |
no test coverage detected