cosminneaga / dpa

Docker Python Apis
https://dpa.cosminneaga.dev/hello
0 stars 0 forks source link

Gracefully handle axios errors in all axios requests #11

Closed cosminneaga closed 1 year ago

cosminneaga commented 1 year ago

The following axios template will be used across the whole app from now on:

try {
    const req = await this.axios.put(
        "/register", {
            ...this.form
        }, {
            headers: {
                "x-access-token": this.$cookies.get("X-Access-Token"),
            },
        }
    );

    this.form = {
        firstName: '',
        lastName: '',
        email: '',
        password: '',
    }

    this.$toast.success("User registered successfully!");
} catch (e: any) {
    this.$toast.error(e.message);
}