(url: string, body: object)
| 27 | } |
| 28 | |
| 29 | async function httpPost(url: string, body: object): Promise<{ status: number; body: string }> { |
| 30 | return new Promise((resolve, reject) => { |
| 31 | const req = http.request( |
| 32 | url, |
| 33 | { |
| 34 | method: "POST", |
| 35 | headers: { "Content-Type": "application/json" }, |
| 36 | }, |
| 37 | (res) => { |
| 38 | const chunks: Buffer[] = []; |
| 39 | res.on("data", (c) => chunks.push(c)); |
| 40 | res.on("end", () => |
| 41 | resolve({ |
| 42 | status: res.statusCode!, |
| 43 | body: Buffer.concat(chunks).toString(), |
| 44 | }), |
| 45 | ); |
| 46 | }, |
| 47 | ); |
| 48 | req.on("error", reject); |
| 49 | req.write(JSON.stringify(body)); |
| 50 | req.end(); |
| 51 | }); |
| 52 | } |
| 53 | |
| 54 | // --------------------------------------------------------------------------- |
| 55 | // Tests |
no test coverage detected
searching dependent graphs…