(req)
| 17 | } |
| 18 | |
| 19 | const concatStringPromise = (req) => { |
| 20 | return new Promise((res, rej) => { |
| 21 | let data = [] |
| 22 | req.on('data', (chunk) => { |
| 23 | data.push(chunk) |
| 24 | }) |
| 25 | req.on('end', () => { |
| 26 | res(Buffer.concat(data).toString('utf-8')) |
| 27 | }) |
| 28 | req.on('error', rej) |
| 29 | }) |
| 30 | } |
| 31 | |
| 32 | const json = async (req) => { |
| 33 | const string = await concatStringPromise(req) |