listo
This commit is contained in:
@@ -9,6 +9,7 @@ const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const get = async (body) => {
|
||||
let year = validar.validarNumero(body.year, 4);
|
||||
let path = `csv/${year}_cuestionario_programa.csv`;
|
||||
|
||||
return Servicio.findAll({
|
||||
include: [
|
||||
@@ -22,7 +23,6 @@ const get = async (body) => {
|
||||
}).then((res) => {
|
||||
let data = [];
|
||||
let csvString = '';
|
||||
let path = `csv/${year}_cuestionarios_programa.csv`;
|
||||
|
||||
for (let i = 0; i < res.length; i++)
|
||||
data.push({
|
||||
@@ -47,10 +47,7 @@ const get = async (body) => {
|
||||
} catch (err) {}
|
||||
csvString = convertArrayToCSV(data);
|
||||
fs.appendFile(path, csvString, (err) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
throw new Error('hubo un problema al crear el archivo csv.');
|
||||
}
|
||||
if (err) throw new Error(err);
|
||||
});
|
||||
return {
|
||||
message: `Se creo/actualizo correctamente el csv del cuestionario de programa del año ${year}`,
|
||||
|
||||
Reference in New Issue
Block a user