(
endpoint: string,
config?: AxiosRequestConfig,
ttl?: number
)
| 54 | } |
| 55 | |
| 56 | protected async get<T>( |
| 57 | endpoint: string, |
| 58 | config?: AxiosRequestConfig, |
| 59 | ttl?: number |
| 60 | ): Promise<T> { |
| 61 | const cacheKey = this.serializeCacheKey(endpoint, { |
| 62 | ...config?.params, |
| 63 | headers: config?.headers, |
| 64 | }); |
| 65 | const cachedItem = this.cache?.get<T>(cacheKey); |
| 66 | if (cachedItem) { |
| 67 | return cachedItem; |
| 68 | } |
| 69 | |
| 70 | const response = await this.axios.get<T>(endpoint, config); |
| 71 | |
| 72 | if (this.cache && ttl !== 0) { |
| 73 | this.cache.set(cacheKey, response.data, ttl ?? DEFAULT_TTL); |
| 74 | } |
| 75 | |
| 76 | return response.data; |
| 77 | } |
| 78 | |
| 79 | protected async post<T>( |
| 80 | endpoint: string, |
no test coverage detected