Advertisement
linuxyamigos

Untitled

Apr 1st, 2020
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. async insert () {
  2.           let formData = new FormData();
  3.           formData.append('file', this.file);
  4.          
  5.           const response = await this.$axios.post('http://elgrove.co/api/v1/files',
  6.               formData,
  7.               {
  8.                   headers: {
  9.                       'Content-Type': 'multipart/form-data',
  10.                       'Authorization': `Bearer ${this.$store.state.auth.authUser.accessToken}`
  11.                   }
  12.               }
  13.           );
  14.          
  15.           const file_id = response.data.data.uploaded[0].id;
  16.           console.log('FILE_ID', file_id);
  17.  
  18.           const response2 = await this.$axios.request({
  19.             url: `http://elgrove.co/api/v1/bills`,  
  20.             method: 'post',
  21.             headers: {
  22.                 'Authorization': `Bearer ${this.$store.state.auth.authUser.accessToken}`
  23.             },
  24.             data: this.editedItem
  25.           });
  26.  
  27.           const uid = response2.data.data.id;
  28.          
  29.           this.editedItem.id = uid;  
  30.           this.editedItem.file = file_id; // requiero del file_id
  31.           this.regs.push(this.editedItem);  
  32.           this.pagination.totalItems++;
  33.       },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement