Onitemcomplete response scope #1048

Open
opened 2018-08-19 16:39:17 +00:00 by akshaykatale99 · 0 comments
akshaykatale99 commented 2018-08-19 16:39:17 +00:00 (Migrated from github.com)

How can i access the onitemcomplete response outside of Uploader.onitemcomplete

here is my code...

add(data,action){
    this.data.loader = true;

    this.uploader.uploadAll();
    this.uploader.onAfterAddingFile = (file) => { file.withCredentials = false; };
    this.uploader.onCompleteItem = (item: any, response: any, status: any, headers: any) => {
  
      this.data.dp = JSON.parse(response);
  **HERE IS THE RESPONSE**  
     };
      //console.log(this.data.dp);
     var frmData = JSON.stringify({'fname': data.fname,'mname':data.mname,'lname':data.lname, 
'contact':data.phone, 'email':data.email, 'address':data.address, 'country':data.country, 'state':data.state, 
'pin':data.pin, 'uimg':**WANT TO  ACCESS IT HERE**});
     console.log(this.data.headers);
     if(action == 'Save'){

     this.http.post("http://127.0.0.1/ci/index.php/api/account/register",frmData,this.options)
      .map(res => res.json())
      .subscribe(data => {
      this.data.loader = false;
        	  this.data.message = data.message;
    
            this.snackBar.open('Registered Successfully.', '', {
              duration: 3000,
            });
          }
    
        else {
          this.snackBar.open(data.message, '', {
              duration: 3000,
            });
        }

        	  	this.data.fname = '';
        this.data.mname = '';
        this.data.lname = '';
        this.data.phone = '';
        this.data.email = '';
        this.data.address = '';
        this.data.pin = '';
        this.data.state = '';
        this.data.country = '';

  		
	      },error => {
	      this.data.message = 'Error';
	      });


  }
How can i access the onitemcomplete response outside of Uploader.onitemcomplete here is my code... add(data,action){ this.data.loader = true; this.uploader.uploadAll(); this.uploader.onAfterAddingFile = (file) => { file.withCredentials = false; }; this.uploader.onCompleteItem = (item: any, response: any, status: any, headers: any) => { this.data.dp = JSON.parse(response); **HERE IS THE RESPONSE** }; //console.log(this.data.dp); var frmData = JSON.stringify({'fname': data.fname,'mname':data.mname,'lname':data.lname, 'contact':data.phone, 'email':data.email, 'address':data.address, 'country':data.country, 'state':data.state, 'pin':data.pin, 'uimg':**WANT TO ACCESS IT HERE**}); console.log(this.data.headers); if(action == 'Save'){ this.http.post("http://127.0.0.1/ci/index.php/api/account/register",frmData,this.options) .map(res => res.json()) .subscribe(data => { this.data.loader = false; this.data.message = data.message; this.snackBar.open('Registered Successfully.', '', { duration: 3000, }); } else { this.snackBar.open(data.message, '', { duration: 3000, }); } this.data.fname = ''; this.data.mname = ''; this.data.lname = ''; this.data.phone = ''; this.data.email = ''; this.data.address = ''; this.data.pin = ''; this.data.state = ''; this.data.country = ''; },error => { this.data.message = 'Error'; }); }
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#1048