p
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
export default function handler(req, res) {
|
||||
const sqlite3 = require('sqlite3').verbose();
|
||||
|
||||
console.log(req.body)
|
||||
// console.log(req.body)
|
||||
// Open a new database connection
|
||||
let uname, status, type, start_month, start_date, end_date, klas, lang, phone, pass, annual, early_start_programme, toddlers, interakto, email, country, state, city, address, school="";
|
||||
|
||||
@@ -26,18 +26,30 @@ export default function handler(req, res) {
|
||||
if(req.body.address) address =req.body.address;
|
||||
if(req.body.school) school =req.body.school;
|
||||
const db = new sqlite3.Database('data/appUser.db');
|
||||
var msg=null;
|
||||
console.log(req.body.userId)
|
||||
db.run(`UPDATE user SET uname = ?, status = ?, type = ?, start_month = ?, start_date = ?, end_date = ?, klas = ?, lang = ?, phone = ?, annual = ?, early_start_programme = ?, toddlers = ?, interakto = ?, email = ?, country = ?, state = ?, city = ?, address = ?, school = ? WHERE id = ? `, [ uname, status, type, start_month, start_date, end_date, klas, lang, phone, annual, early_start_programme, toddlers, interakto, email, country, state, city, address, school, req.body.userId],
|
||||
function(err) {
|
||||
if (err) {
|
||||
res.status(400).json({ msg: 'Err400D' });
|
||||
return console.log(err.message);
|
||||
msg={ msg: 'Err400D' };
|
||||
// res.status(400).send({ msg: 'Err400D' });
|
||||
// return console.log(err.message);
|
||||
}
|
||||
res.status(200).json({ msg: 'ok' });
|
||||
// console.log('message');
|
||||
msg="{ msg: 'ok' }";
|
||||
// res.statusCode = 200;
|
||||
// res.setHeader('Content-Type', 'application/json');
|
||||
// res.setHeader('Cache-Control', 'max-age=180000');
|
||||
// res.end(JSON.stringify({ msg: 'ok' }));
|
||||
// res.status(200).json({ msg: 'ok' });
|
||||
}
|
||||
);
|
||||
db.close();
|
||||
|
||||
res.statusCode = 200;
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.setHeader('Cache-Control', 'max-age=180000');
|
||||
res.end(JSON.stringify(msg));
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user