feat: adding try catch
This commit is contained in:
@@ -25,26 +25,38 @@ export class Partner {
|
||||
}
|
||||
|
||||
async getData() {
|
||||
const response = await http.get(`/users/partner?page=${this.page}&pageSize=${this.pageSize}`);
|
||||
|
||||
this.data = response.body.data.map((item, idx) => {
|
||||
item.key = idx;
|
||||
return item
|
||||
}) ?? []
|
||||
try {
|
||||
const response = await http.get(`/users/partner?page=${this.page}&pageSize=${this.pageSize}`);
|
||||
|
||||
this.total_data = response.body.count ?? 0
|
||||
this.data = response.body.data.map((item, idx) => {
|
||||
item.key = idx;
|
||||
return item
|
||||
}) ?? []
|
||||
|
||||
this.total_data = response.body.count ?? 0
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async create(data) {
|
||||
const response = await http.post('/users/partner').send(data);
|
||||
await this.getData();
|
||||
return response;
|
||||
try {
|
||||
const response = await http.post('/users/partner').send(data);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id, data) {
|
||||
const response = await http.put(`/users/partner/${id}`).send(data);
|
||||
await this.getData();
|
||||
return response;
|
||||
try {
|
||||
const response = await http.put(`/users/partner/${id}`).send(data);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
// async updateStatus(id, data) {
|
||||
@@ -54,15 +66,23 @@ export class Partner {
|
||||
// }
|
||||
|
||||
async delete(id) {
|
||||
const response = await http.del(`/product/${id}`);
|
||||
await this.getData();
|
||||
return response;
|
||||
try {
|
||||
const response = await http.del(`/product/${id}`);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async changeStatus(id, status) {
|
||||
const response = await http.get(`/users/partner/${id}/${status}`);
|
||||
await this.getData();
|
||||
return response;
|
||||
try {
|
||||
const response = await http.get(`/users/partner/${id}/${status}`);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user