From f8c3d1e6db07710740ddc79081728563bf8110b3 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Wed, 20 Nov 2019 18:00:17 +0530 Subject: [PATCH] refactor: use async await approach --- pages/graphql.vue | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pages/graphql.vue b/pages/graphql.vue index 25c8a7f47..c49b48ded 100644 --- a/pages/graphql.vue +++ b/pages/graphql.vue @@ -148,11 +148,10 @@ export default { // The nuxt axios module will hide it when the request is made. this.$nuxt.$loading.start(); - axios - .post(this.url, { - query: gql.getIntrospectionQuery() + try { + const res = await axios.post(this.url, { + query: gql.getIntrospectionQuery() }) - .then(res => { const schema = gql.buildClientSchema(res.data.data); this.schemaString = gql.printSchema(schema, { commentDescriptions: true @@ -216,8 +215,7 @@ export default { this.$toast.info(`Finished in ${duration}ms`, { icon: "done" }); - }) - .catch(error => { + } catch(err) { this.$nuxt.$loading.finish(); this.schemaString = error + ". Check console for details."; this.$toast.error(error + " (F12 for details)", {