* Convenience method for developers familiar with axios.request(config) * * @see https://github.com/axios/axios#axiosrequestconfig * @see https://github.com/axios/axios#request-config
({ url = '/', json = undefined, data = undefined, method = 'GET', params = new Map<string, any>() })
| 411 | * @see {@link https://github.com/axios/axios#request-config} |
| 412 | */ |
| 413 | async request ({ url = '/', json = undefined, data = undefined, method = 'GET', params = new Map<string, any>() }): Promise<any> { |
| 414 | console.debug('PeerFetch.request entered.', { url, json, data, method, params }) |
| 415 | var esc = encodeURIComponent |
| 416 | var query = Object.keys(params) |
| 417 | .map(k => esc(k) + '=' + esc(params.get(k))) |
| 418 | .join('&') |
| 419 | url += '?' + query |
| 420 | console.debug('PeerFetch.request', { url, json, data, method, query }) |
| 421 | const request = { |
| 422 | url, |
| 423 | json, |
| 424 | data, |
| 425 | method |
| 426 | } |
| 427 | // get a ticket that matches the request |
| 428 | // and use it to claim the corresponding |
| 429 | // response when available |
| 430 | const ticket = this._enqueueRequest(request) |
| 431 | const response = await this._receiveResponse(ticket) |
| 432 | console.debug('PeerFetch.request ended. Returning response:', { url, method, params, response }) |
| 433 | return response |
| 434 | } |
| 435 | |
| 436 | /** |
| 437 | * |
no test coverage detected