MCPcopy Create free account
hub / github.com/ambianic/peerfetch / request

Method request

javascript/src/peerfetch.ts:413–434  ·  view source on GitHub ↗

* 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>() })

Source from the content-addressed store, hash-verified

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 *

Callers 4

getMethod · 0.95
putMethod · 0.95
postMethod · 0.95
fetchMethod · 0.95

Calls 3

_enqueueRequestMethod · 0.95
_receiveResponseMethod · 0.95
getMethod · 0.80

Tested by

no test coverage detected