From 4474a883bc8b1d79c1d50380cd17c25a05fdfcfa Mon Sep 17 00:00:00 2001 From: AuroraHuang22 Date: Fri, 16 Feb 2024 19:50:00 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Handle=20default=20info=20when?= =?UTF-8?q?=20user=20data=20is=20unavailable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/IscnRegisterForm.vue | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/components/IscnRegisterForm.vue b/components/IscnRegisterForm.vue index dbdef66a..dd80d0ce 100644 --- a/components/IscnRegisterForm.vue +++ b/components/IscnRegisterForm.vue @@ -1140,25 +1140,19 @@ export default class IscnRegisterForm extends Vue { } async fetchUserInfoByAddress(address: any) { + let userData: any = null; try { - const { data } = await this.$axios.get(getUserInfoMinByAddress(address)) - return { - name: data?.displayName || address, - wallet: [{ content: address, id: 1, type: 'like', isOpenOptions: false }], - url: [], - likerId: data?.user || '', - authorDescription: data?.description || 'Publisher', - } + ({ data: userData } = await this.$axios.get(getUserInfoMinByAddress(address))) } catch (error) { // eslint-disable-next-line no-console console.error(error) - return { - name: address, - wallet: [{ content: address, id: 1, type: 'like', isOpenOptions: false }], - url: [], - likerId: '', - authorDescription: 'Publisher', - } + } + return { + name: userData?.displayName || address, + wallet: [{ content: address, id: 1, type: 'like', isOpenOptions: false }], + url: [], + likerId: userData?.user || '', + authorDescription: userData?.description || 'Publisher', } }