Commit 9f6ee97a by Billy Larru

implementado array de promesas

parent 5f36ddb0
......@@ -192,56 +192,6 @@ function guardarCambios() {
}
});
// let mrd = {
// id: 1,
// sede_descripcion: "ARENALES",
// asistencia_entrada: "10:00",
// asistencia_salida: "22:22"
// };
//
// ajaxWebService.patch("http://sistem16:666/proyeccion/1", mrd)
// setInterval(() => {
// console.log(moment().format("YYYY/DD/MM HH:MM:SS s"))
// }, 500)
// let timer1 = () => {
// return new Promise((resolve, reject) => {
// resolve(ajaxWebService.get("https://yts.am/api/v2/list_movies.json"))
// });
// }
//
// let timer2 = () => {
// return new Promise((resolve, reject) => {
// let mrd = {
// id: 2,
// sede_descripcion: "ARENALES",
// asistencia_entrada: "10:00",
// asistencia_salida: "22:22"
// };
//
// resolve(ajaxWebService.get("https://yts.am/api/v2/list_movies.json?sort=seeds&limit=15"))
// })
// }
// Promise.all([ajaxWebService.get("https://yts.am/api/v2/list_movies.json"), ajaxWebService.get("https://yts.am/api/v2/list_movies.json?sort=seeds&limit=15")])
// .then((value) => {
// console.log(`FIN`, moment().format("YYYY/DD/MM HH:MM:SS s"))
// debugger;
// })
Promise.all(dataRequest.map(p => ajaxWebService.patch(`${URI_POLICIA_PROYECCION}/${p.id}`, p)))
.then(axios.spread(function (...pms) {
console.log("POR FIN")
}))
let promises = []
swal({
title: 'Está seguro de guardar los cambios?',
text: "",
......@@ -252,31 +202,22 @@ function guardarCambios() {
confirmButtonText: 'Sí, guardar!'
}).then((result) => {
if (result.value) {
// dataRequest.forEach(d => {
// promises.push(ajaxWebService.patch(`${URI_POLICIA_PROYECCION}/${d.id}`, d))
// });
// Promise.all([get1(), get2()])
// .then(function ([acct, perms]) {
// swal(
// {
// type: 'success',
// title: '¡Se guardaron los cambios correctamente!',
// showConfirmButton: false,
// timer: 1500
// }
// );
// });
let promises = dataRequest.map(p => ajaxWebService.patch(`${URI_POLICIA_PROYECCION}/${p.id}`, p));
Promise.all(promises)
.then(axios.spread(function (...responses) {
swal(
{
type: 'success',
title: '¡Se guardaron los cambios correctamente!',
showConfirmButton: false,
timer: 1500
}
);
}))
}
})
// ajaxWebService.patch(URI_POLICIA_PROYECCION, dataRequest).then((response) => {
//
// });
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment