this.$auth.loginWith
returns a promise, but I am unsure if I should wrap it in a try/catch or just use a catch
on the promise.
Which is the correct way?
Try/Catch:
async login() {
try {
const response = await this.$auth.loginWith('laravelSanctum', {
data: {
email: 'xxx',
password: 'xxx',
},
});
this.$auth.setUser(response.data.data);
} catch (e) {
}
},
Catch:
async login() {
const response = await this.$auth.loginWith('laravelSanctum', {
data: {
email: 'xxx',
password: 'xxx',
},
}).catch(function(e) {
});
this.$auth.setUser(response.data.data);
},