Skip to content

Commit 0b073d4

Browse files
committed
docs: race condition in example
Close #2691
1 parent 51d40a5 commit 0b073d4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

docs/guide/advanced/data-fetching.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ export default {
5555
fetchData () {
5656
this.error = this.post = null
5757
this.loading = true
58+
const fetchedId = this.$route.params.id
5859
// replace `getPost` with your data fetching util / API wrapper
59-
getPost(this.$route.params.id, (err, post) => {
60+
getPost(fetchedId, (err, post) => {
61+
// make sure this request is the last one we did, discard otherwise
62+
if (this.$route.params.id !== fetchedId) return
6063
this.loading = false
6164
if (err) {
6265
this.error = err.toString()

0 commit comments

Comments
 (0)