node.js - Node appendFile not appending data chunk to file on filesystem -
i have program trying values request using curl , store them in file , serve stored content back. decision store or append contents in file based on query parameter appendflag when run program getting in console " true " , " appending " suggests indeed reads flag goes if part somehow appendfile function not working. var http = require('http'); var url = require('url'); var querystring = require('querystring'); var fs = require('fs'); http.createserver(function(request,response){ var str = request.url.split('?')[1]; var query = querystring.parse(str); var writestream = fs.createwritestream(query['filename']); console.log("query - "); console.log(query["appendflag"]); request.on('data',function(chunk){ if(query["appendflag"]=="true"){ console.log("appending"); fs.appendfile(query['filename'],c...