Advertisement
Guest User

Untitled

a guest
Mar 27th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static postDataToServer(surveyData, guid) {
  2.         return HardwareHttpService.postData(surveyData, guid).then(response => {
  3.             var requests = [];
  4.             var namePhotos = surveyData.map(x => x.namePhotos);
  5.             namePhotos.forEach(photoBundle => {
  6.                 var data = response.data.data;
  7.                 var correctId = data.registers.filter(x => x.name == photoBundle.registerName)[0].id;
  8.                 var photoDataPattern = {
  9.                     retailerId: data.retailerId,
  10.                     dealId: data.dealId,
  11.                     registerId: correctId,
  12.                     type: data.type
  13.                 };
  14.  
  15.                 photoBundle.photos.uploadPhoto0 && requests.push(
  16.                     HardwareHttpService.createRequest({ ...photoDataPattern, index: 0, photo: photoBundle.photos.uploadPhoto0 })
  17.                 );
  18.                 photoBundle.photos.uploadPhoto1 && requests.push(
  19.                     HardwareHttpService.createRequest({ ...photoDataPattern, index: 1, photo: photoBundle.photos.uploadPhoto1 })
  20.                 );
  21.                 photoBundle.photos.uploadPhoto2 && requests.push(
  22.                     HardwareHttpService.createRequest({ ...photoDataPattern, index: 2, photo: photoBundle.photos.uploadPhoto2 })
  23.                 );
  24.                 photoBundle.photos.uploadPhoto3 && requests.push(
  25.                     HardwareHttpService.createRequest({ ...photoDataPattern, index: 3, photo: photoBundle.photos.uploadPhoto3 })
  26.                 );
  27.             });
  28.  
  29.             return Promise.all(requests);
  30.         });
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement