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.
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)", {