(req)
| 14 | |
| 15 | // Async function to handle reading the body of the request |
| 16 | const getRequestBody = async (req) => { |
| 17 | return new Promise((resolve, reject) => { |
| 18 | let body = `` |
| 19 | req.on(`data`, (chunk) => (body += chunk.toString())) |
| 20 | req.on(`end`, () => resolve(body)) |
| 21 | req.on(`error`, reject) |
| 22 | }) |
| 23 | } |
| 24 | |
| 25 | const JSON_HEADERS = { |
| 26 | "Content-Type": `application/json`, |