Added delete functionality
This commit is contained in:
		
							parent
							
								
									5b697d7810
								
							
						
					
					
						commit
						f6d119c852
					
				| @ -42,6 +42,15 @@ | |||||||
|         type="primary" |         type="primary" | ||||||
|         >Save & Close</el-button |         >Save & Close</el-button | ||||||
|       > |       > | ||||||
|  |       <el-button | ||||||
|  |         type="danger" | ||||||
|  |         @click=" | ||||||
|  |           deleteSecret(); | ||||||
|  |           closeDialog(); | ||||||
|  |         " | ||||||
|  |         v-if="this.method === 'PUT'" | ||||||
|  |         >Delete</el-button | ||||||
|  |       > | ||||||
|     </div> |     </div> | ||||||
|   </div> |   </div> | ||||||
| </template> | </template> | ||||||
| @ -87,7 +96,7 @@ export default { | |||||||
|         }, |         }, | ||||||
|         body: JSON.stringify(bodyData), |         body: JSON.stringify(bodyData), | ||||||
|       }; |       }; | ||||||
|       console.log(requestOptions); |       // console.log(requestOptions); | ||||||
|       await fetch(url, requestOptions) |       await fetch(url, requestOptions) | ||||||
|         .then((response) => response.json()) |         .then((response) => response.json()) | ||||||
|         .then((data) => console.log(data)); |         .then((data) => console.log(data)); | ||||||
| @ -100,6 +109,25 @@ export default { | |||||||
|         (this.form.secret = ""); |         (this.form.secret = ""); | ||||||
|       this.$emit("close", true); |       this.$emit("close", true); | ||||||
|     }, |     }, | ||||||
|  | 
 | ||||||
|  |     async deleteSecret() { | ||||||
|  |       const url = `${this.apiBaseUrl}/secret`; | ||||||
|  |       const token = sessionStorage.getItem("token"); | ||||||
|  |       const bodyData = { data: btoa(JSON.stringify(this.form)) }; | ||||||
|  |       bodyData["id"] = this.id; | ||||||
|  |       const requestOptions = { | ||||||
|  |         method: "DELETE", | ||||||
|  |         headers: { | ||||||
|  |           "Content-Type": "application/json", | ||||||
|  |           Authorization: `Bearer ${token}`, | ||||||
|  |         }, | ||||||
|  |         body: JSON.stringify(bodyData), | ||||||
|  |       }; | ||||||
|  |       // console.log(requestOptions); | ||||||
|  |       await fetch(url, requestOptions) | ||||||
|  |         .then((response) => response.json()) | ||||||
|  |         .then((data) => console.log(data)); | ||||||
|  |     }, | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   created() { |   created() { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user