chore(refactor): switch to async/await approach (#317)

chore(refactor): switch to async/await approach
This commit is contained in:
Liyas Thomas
2019-11-20 19:43:22 +05:30
committed by GitHub

View File

@@ -140,7 +140,7 @@ export default {
};
},
methods: {
getSchema() {
async getSchema() {
const startTime = Date.now();
this.schemaString = "Loading...";
@@ -148,11 +148,11 @@ export default {
// The nuxt axios module will hide it when the request is made.
this.$nuxt.$loading.start();
axios
.post(this.url, {
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,15 +216,14 @@ export default {
this.$toast.info(`Finished in ${duration}ms`, {
icon: "done"
});
})
.catch(error => {
} catch(error) {
this.$nuxt.$loading.finish();
this.schemaString = error + ". Check console for details.";
this.$toast.error(error + " (F12 for details)", {
icon: "error"
});
console.log("Error", error);
});
}
}
}
};