I'm just trying to understand the node stream and trying to create a pipe. so reading a file and writing to another writeable stream and again passing to res since that is also the writeable stream.
But it throws the error
Error [ERR_STREAM_CANNOT_PIPE]: Cannot pipe, not readable
Please let me know the reason of the failure and also have a look on below code for intel.
const http = require('http')
const fs = require('fs')
var server = http.createServer((req, res)=>{
//created the read strem
let file = fs.createReadStream('./temp_files/file1.txt')
// pipig this RES, since is RES is the aother writeable stream
let des = fs.createWriteStream('./temp_files/final.tct')
file.pipe(des).pipe(res) // ERROR <<<------------------------------
})
server.listen(9090, (req, res)=>{
console.log("runnig at port 9090")
})