(data?: string)
| 39 | } |
| 40 | |
| 41 | private _fetch(data?: string) { |
| 42 | const isPost = data !== undefined; |
| 43 | const headers = new Headers(this.opts.extraHeaders); |
| 44 | |
| 45 | if (isPost) { |
| 46 | headers.set("content-type", "text/plain;charset=UTF-8"); |
| 47 | } |
| 48 | |
| 49 | this.socket._cookieJar?.appendCookies(headers); |
| 50 | |
| 51 | return fetch(this.uri(), { |
| 52 | method: isPost ? "POST" : "GET", |
| 53 | body: isPost ? data : null, |
| 54 | headers, |
| 55 | credentials: this.opts.withCredentials ? "include" : "omit", |
| 56 | }).then((res) => { |
| 57 | // @ts-ignore getSetCookie() was added in Node.js v19.7.0 |
| 58 | this.socket._cookieJar?.parseCookies(res.headers.getSetCookie()); |
| 59 | |
| 60 | return res; |
| 61 | }); |
| 62 | } |
| 63 | } |
no test coverage detected