From beaf0696180c4884f4a1d677c9f5a1f6988114af Mon Sep 17 00:00:00 2001 From: Aldino Kemal Date: Sun, 14 Jul 2024 18:05:19 +0700 Subject: [PATCH] fix: show error message --- src/views/components/AppLoginWithCode.js | 25 ++++++++---------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/views/components/AppLoginWithCode.js b/src/views/components/AppLoginWithCode.js index 00c1be5..de1cadf 100644 --- a/src/views/components/AppLoginWithCode.js +++ b/src/views/components/AppLoginWithCode.js @@ -39,29 +39,20 @@ export default { if (this.submitting) return; try { this.submitting = true; - const { data } = await this.submitApi(); - this.pair_code = data.results.pair_code; - } catch (err) { - showErrorInfo(err); - } finally { - this.submitting = false; - } - }, - - async submitApi() { - try { - return http.get(`/app/login-with-code`, { + const { data } = await http.get(`/app/login-with-code`, { params: { phone: this.phone, }, }); - } catch (error) { - if (error.response) { - throw Error(error.response.data.message); + this.pair_code = data.results.pair_code; + } catch (err) { + if (err.response) { + return showErrorInfo(err.response.data.message); } - throw Error(error.message); + return showErrorInfo(err.message); + } finally { + this.submitting = false; } - }, }, template: `