samedi 21 novembre 2020

Vuejs - Bound checkboxes with Vuex/RestAPI are left checked on failed request

I made 2 jsfiddles to demonstrate my issue.

In the first one, the promise resolves (mocking successful restapi response) and everything works as expected: https://jsfiddle.net/DvDty/ruwh92gv/

await new Promise((resolve, reject) => {
    resolve(true)
})

In the second one, the promise is rejected (mocking failed restapi response): https://jsfiddle.net/DvDty/yxg75npw/

await new Promise((resolve, reject) => {
    reject(false)
})

The issue: even though I'm not updating the state in any way, the checkbox is left checked. Seems like v-model is overriding the store, and the people getter is not triggered since there was no actual change in the state that it is bound to. How can I fix this?




Aucun commentaire:

Enregistrer un commentaire