Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

refactor: use async await approach

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