* @summary Send HTTP POST Request with Body to configured HTTP Endpoint.
(
method: string,
params: unknown[],
isCacheable?: boolean,
)
| 163 | * @summary Send HTTP POST Request with Body to configured HTTP Endpoint. |
| 164 | */ |
| 165 | async send<T>( |
| 166 | method: string, |
| 167 | params: unknown[], |
| 168 | isCacheable?: boolean, |
| 169 | ): Promise<T> { |
| 170 | this.#stats.total.requests++; |
| 171 | |
| 172 | const [, body] = this.#coder.encodeJson(method, params); |
| 173 | let resultPromise: Promise<T> | null = isCacheable |
| 174 | ? (this.#callCache.get(body) as Promise<T>) |
| 175 | : null; |
| 176 | |
| 177 | // eslint-disable-next-line @typescript-eslint/no-misused-promises |
| 178 | if (!resultPromise) { |
| 179 | resultPromise = this._send(body); |
| 180 | |
| 181 | if (isCacheable) { |
| 182 | this.#callCache.set(body, resultPromise); |
| 183 | } |
| 184 | } else { |
| 185 | this.#stats.total.cached++; |
| 186 | } |
| 187 | |
| 188 | return resultPromise; |
| 189 | } |
| 190 | |
| 191 | async _send<T>(body: string): Promise<T> { |
| 192 | this.#stats.active.requests++; |
no test coverage detected