Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static postDataToServer(surveyData, guid) {
- return HardwareHttpService.postData(surveyData, guid).then(response => {
- var requests = [];
- var namePhotos = surveyData.map(x => x.namePhotos);
- namePhotos.forEach(photoBundle => {
- var data = response.data.data;
- var correctId = data.registers.filter(x => x.name == photoBundle.registerName)[0].id;
- var photoDataPattern = {
- retailerId: data.retailerId,
- dealId: data.dealId,
- registerId: correctId,
- type: data.type
- };
- photoBundle.photos.uploadPhoto0 && requests.push(
- HardwareHttpService.createRequest({ ...photoDataPattern, index: 0, photo: photoBundle.photos.uploadPhoto0 })
- );
- photoBundle.photos.uploadPhoto1 && requests.push(
- HardwareHttpService.createRequest({ ...photoDataPattern, index: 1, photo: photoBundle.photos.uploadPhoto1 })
- );
- photoBundle.photos.uploadPhoto2 && requests.push(
- HardwareHttpService.createRequest({ ...photoDataPattern, index: 2, photo: photoBundle.photos.uploadPhoto2 })
- );
- photoBundle.photos.uploadPhoto3 && requests.push(
- HardwareHttpService.createRequest({ ...photoDataPattern, index: 3, photo: photoBundle.photos.uploadPhoto3 })
- );
- });
- return Promise.all(requests);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement