refactor: use async await approach

This commit is contained in:
jamesgeorge007
2019-11-20 18:00:17 +05:30
parent 38513d3eed
commit f8c3d1e6db

View File

@@ -148,11 +148,10 @@ export default {
// The nuxt axios module will hide it when the request is made. // The nuxt axios module will hide it when the request is made.
this.$nuxt.$loading.start(); this.$nuxt.$loading.start();
axios try {
.post(this.url, { const res = await axios.post(this.url, {
query: gql.getIntrospectionQuery() query: gql.getIntrospectionQuery()
}) })
.then(res => {
const schema = gql.buildClientSchema(res.data.data); const schema = gql.buildClientSchema(res.data.data);
this.schemaString = gql.printSchema(schema, { this.schemaString = gql.printSchema(schema, {
commentDescriptions: true commentDescriptions: true
@@ -216,8 +215,7 @@ export default {
this.$toast.info(`Finished in ${duration}ms`, { this.$toast.info(`Finished in ${duration}ms`, {
icon: "done" icon: "done"
}); });
}) } catch(err) {
.catch(error => {
this.$nuxt.$loading.finish(); this.$nuxt.$loading.finish();
this.schemaString = error + ". Check console for details."; this.schemaString = error + ". Check console for details.";
this.$toast.error(error + " (F12 for details)", { this.$toast.error(error + " (F12 for details)", {