update for id bug 46

This commit is contained in:
Mohamed Nouffer
2022-11-16 15:38:03 +05:30
parent 5a46f16b7d
commit b77cd8c7bb

View File

@ -142,8 +142,8 @@ app.post('/csv', (req, res, next) => {
try {
const path = '/var/www/html/appexe/natnats/23/bin/mobileweb2/resources/database/user_record.csv';
if (fs.existsSync(path)) {
fs.createReadStream(path)
.pipe(parse({ delimiter: ",", from_line: 2 }))
const readable = fs.createReadStream(path);
readable.pipe(parse({ delimiter: ",", from_line: 2 }))
.on("data", function (row) {
console.log("--- r-0 ----", row[0]);
if(row[0] === _userEmail){
@ -165,16 +165,17 @@ app.post('/csv', (req, res, next) => {
});
fs.destroy();
if(_res === ""){
fs.appendFile(path, csv, function (err) {
if (err) throw err;
console.log('The "data to append" was appended to file!');
});
// writetoFile(csv);
_res = _jsessionid;
res.send({'id': _res});
}
readable.on("close", () => {
if(_res === ""){
fs.appendFile(path, csv, function (err) {
if (err) throw err;
console.log('The "data to append" was appended to file!');
});
// writetoFile(csv);
_res = _jsessionid;
res.send({'id': _res});
}
});
}
} catch(err) {
console.log("---error -----");