* fetch fetches the request path. * The request path must be rooted!
(requestPath: string, opts?: RequestInit, query?: { [key: string]: string })
| 59 | * The request path must be rooted! |
| 60 | */ |
| 61 | public fetch(requestPath: string, opts?: RequestInit, query?: { [key: string]: string }): Promise<Response> { |
| 62 | const address = ensureAddress(this.hs, "http") |
| 63 | if (typeof address === "string") { |
| 64 | throw new Error("Cannot fetch socket path") |
| 65 | } |
| 66 | address.pathname = requestPath |
| 67 | if (query) { |
| 68 | Object.keys(query).forEach((key) => { |
| 69 | address.searchParams.append(key, query[key]) |
| 70 | }) |
| 71 | } |
| 72 | return nodeFetch(address.toString(), opts) |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Open a websocket against the request path. |