unknown

db call modulize

const mysql = require('mysql');
const DB_option = require('./db_option');
module.exports = mysql.createConnection(DB_option);
......@@ -19,12 +19,8 @@ module.exports = (server, app) => {
if (err) throw err;
// api의 대답이 있을경우 실행
if (api_res) {
const sql = `INSERT INTO dataset (question,option_1,option_2,option_3,option_4,answer,user_id) VALUES (?,?,?,?,?,?,?)`;
db.query(sql, [question, option[0], option[1], option[2], option[3],machine_body.answer,user_id], function (err, result) {
if (err) throw err;
console.log("dataset successfully inserted into DB")
});
return response.send( { answer: machine_body.answer } );
console.log(api_body);
return response.send("ok");
}
});
}, 60 * 1000); //1분마다 호출
......