Skip to content

Commit

Permalink
docs: race condition in example
Browse files Browse the repository at this point in the history
Close #2691
  • Loading branch information
posva committed Aug 8, 2020
1 parent 51d40a5 commit 0b073d4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion docs/guide/advanced/data-fetching.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ export default {
fetchData () {
this.error = this.post = null
this.loading = true
const fetchedId = this.$route.params.id
// replace `getPost` with your data fetching util / API wrapper
getPost(this.$route.params.id, (err, post) => {
getPost(fetchedId, (err, post) => {
// make sure this request is the last one we did, discard otherwise
if (this.$route.params.id !== fetchedId) return
this.loading = false
if (err) {
this.error = err.toString()
Expand Down

0 comments on commit 0b073d4

Please sign in to comment.