Здравствуйте. А не подскажите, как есть через response вернуть json readable stream в котором chunk object?
const http = require('http');
const { Readable } = require('stream');
http.createServer((request, response) => {
const data = [{ a: 1 }, { b: 2 }, { c: 3 }, { d: 4 }, { e: 5 }];
const readable = Readable.from(data, { objectMode: true });
readable.pipe(response);
}).listen(8080);
events.js:187
throw er; // Unhandled 'error' event
^
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be one of type string or Buffer. Received type object
at write_ (_http_outgoing.js:618:11)
at ServerResponse.write (_http_outgoing.js:586:15)
at Readable.ondata (_stream_readable.js:726:22)
at Readable.emit (events.js:210:5)
at addChunk (_stream_readable.js:308:12)
at readableAddChunk (_stream_readable.js:289:11)
at Readable.push (_stream_readable.js:223:10)
at next (_stream_readable.js:1223:27)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Emitted 'error' event on Readable instance at:
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'ERR_INVALID_ARG_TYPE'
}
Спасибо.