[Vuejs]-Debug VUE app for REST API call protected using Auth0 in VS Code

0👍

By further investigation of the above issue, I notice that using Promise syntax instead of async/await the VS Code debugger seems to work fine (I can inspect error in the debugger).
I suppose is a problem of settings reported in launch.json, but I can’t figure it out why/what.
Below the revised code:

methods: {
    // this method has debug issues
    async callApi2() {
      this.executed = true;
      try {
        const { data } = await this.$http.get(
          "https://gorest.co.in/public-api/posts5"
        );
        this.apiMessage = data;
      } catch (error) {
        this.apiMessage = error.stack;
      }
    },
    // this method without async/await has no debugging issues !!
    callApi() {
      this.executed = true;

      const accessToken = "gjkgkjgk"; //await this.$auth.getTokenSilently();
      this.$http
        .get("/api/external", {
          headers: {
            Authorization: `Bearer ${accessToken}`,
          },
        })
        .then((data) => (this.apiMessage = data))
        .catch(
          (error) =>
            //console.log(err);
            (this.apiMessage = `Error: the server responded with '${error.response.status}: ${error.response.statusText}'`)
        );
    },
  },
};
</script>

Leave a comment