async createItem() {
let record;
let success = false;
this.isLoading= true;
await this.$fetch(`/api/items/${this.params.id}/new/`, {
method: 'POST',
body: JSON.stringify(this.createItemBody),
})
.then(response => response.json())
.then((response) => {
item = response;
success = true;
})
.catch((err) => {
this.isLoading= false;
window.console.log(err);
});
if (success) {
await this.dispatch('fetchSecondItem', id);
this.items.push(item);
this.dispatch('notification', {
type: 'success',
message: 'Item was created.',
});
this.resetForm();
}
this.isLoading= false;
},
item
.then((response) => {
item = response;
success = true;
})
async createItem() {
this.isLoading = true;
try {
let res = await this.$fetch(`/api/items/${this.params.id}/new/`, {
method: "POST",
body: JSON.stringify(this.createItemBody)
});
let json = await res.json();
await this.dispatch("fetchSecondItem", id);
this.items.push(json);
this.dispatch("notification", {
type: "success",
message: "Item was created."
});
this.isLoading = true;
this.resetForm();
} catch (err) {
this.isLoading = false;
console.log(err);
}
}