I am trying to get the data of a PUT request from a http server. I've tried the following:
const http = require('http');
const server = http.createServer(async (req, res) => {
const body = await new Promise(resolve => {
const data = [];
req.on('data', chunk => {
data.push(chunk);
});
req.on('end', () => {
resolve(data.join(''));
});
});
console.log(body);
});
server.listen(80);
But when I make a PUT request to this server with the name 'Test' and the value 'Test' I get the following response:
------WebKitFormBoundary5irMnjtb69WOI025
Content-Disposition: form-data; name="Test"
Test
------WebKitFormBoundary5irMnjtb69WOI025--
How do I make a JSON object of this?