Generado repositorio para consultar la api #86 #87
| @@ -1,54 +1,22 @@ | ||||
| class DjangoApi { | ||||
|   getCustomers() { | ||||
|     return new Promise((resolve, reject) => { | ||||
|       fetch('/don_confiao/api/customers/') | ||||
|         .then(response => response.json()) | ||||
|         .then(data => { | ||||
|           resolve(data); | ||||
|         }) | ||||
|         .catch(error => { | ||||
|           reject(error); | ||||
|         }); | ||||
|     }); | ||||
|     const url = '/don_confiao/api/customers/'; | ||||
|     return this.getRequest(url); | ||||
|   } | ||||
|  | ||||
|   getProducts() { | ||||
|     return new Promise((resolve, reject) => { | ||||
|       fetch('/don_confiao/api/products/') | ||||
|          .then(response => response.json()) | ||||
|          .then(data => { | ||||
|            resolve(data); | ||||
|          }) | ||||
|          .catch(error => { | ||||
|            reject(error); | ||||
|          }); | ||||
|     }); | ||||
|     const url = '/don_confiao/api/products/'; | ||||
|     return this.getRequest(url); | ||||
|   } | ||||
|  | ||||
|   getPaymentMethods() { | ||||
|     return new Promise((resolve, reject) => { | ||||
|       fetch('/don_confiao/payment_methods/all/select_format') | ||||
|          .then(response => response.json()) | ||||
|          .then(data => { | ||||
|            resolve(data); | ||||
|          }) | ||||
|          .catch(error => { | ||||
|            reject(error); | ||||
|          }); | ||||
|     }); | ||||
|     const url = '/don_confiao/payment_methods/all/select_format'; | ||||
|     return this.getRequest(url); | ||||
|   } | ||||
|  | ||||
|   getSummaryPurchase(purchaseId) { | ||||
|     return new Promise ((resolve, reject) => { | ||||
|       fetch(`/don_confiao/resumen_compra_json/${purchaseId}`) | ||||
|         .then(response => response.json()) | ||||
|         .then(data => { | ||||
|           resolve(data); | ||||
|         }) | ||||
|         .catch(error => { | ||||
|           reject(error); | ||||
|         }); | ||||
|     }); | ||||
|     const url = `/don_confiao/resumen_compra_json/${purchaseId}`; | ||||
|     return this.getRequest(url); | ||||
|   } | ||||
|  | ||||
|   createPurchase(purchase) { | ||||
| @@ -75,6 +43,19 @@ class DjangoApi { | ||||
|       }).catch(error => reject(error)); | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   getRequest(url) { | ||||
|     return new Promise ((resolve, reject) => { | ||||
|       fetch(url) | ||||
|         .then(response => response.json()) | ||||
|         .then(data => { | ||||
|           resolve(data); | ||||
|         }) | ||||
|         .catch(error => { | ||||
|           reject(error); | ||||
|         }); | ||||
|     }); | ||||
|   } | ||||
| } | ||||
|  | ||||
| export default DjangoApi; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user