Answer the question
In order to leave comments, you need to log in
How to remove nesting of promises?
Hello, tell me how to remove the nesting of promises in the code?
this.$store.dispatch(GET_ORDER, order).then( () => {
let data = {}
data.id = order
data.order = {status, comment, totalPrice, paymentMethod}
this.$store.dispatch(PATCH_ORDER, data).then( () => {
if (this.responseServer){
this.$refs.modalSend.hide()
this.status=1
}
})
}, () => {
this.$store.dispatch(POST_ORDER, {id, status, comment, totalPrice, paymentMethod}).then( () => {
if (this.responseServer){
this.$refs.modalSend.hide()
this.status = 1
}
})
})
Answer the question
In order to leave comments, you need to log in
like this
this.$store.dispatch(GET_ORDER, order).then(() => {
let data = {};
data.id = order;
data.order = {
status,
comment,
totalPrice,
paymentMethod
};
return this.$store.dispatch(PATCH_ORDER, data);
}).catch(() => {
return this.$store.dispatch(POST_ORDER, {
id,
status,
comment,
totalPrice,
paymentMethod
});
}).then(() => {
if (this.responseServer) {
this.$refs.modalSend.hide();
this.status = 1;
}
});
When the application has
store, you can subscribe handlers to its events and run the behavior, looking at changes in the contents of the store.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question