Nuxt.js: Nuxt 1.1.1 - fetch is not called in the page - possible bug

Created on 17 Jan 2018  路  2Comments  路  Source: nuxt/nuxt.js

After migration from rc11 to 1.1.1 my search component stoped working.

Problem
The fetch method in the page is called only for _first_ search.

SearchComponent

      <div>
        <input type="text" v-model="q" @keyup.enter="doSearch" />
        <button type="button" @click.prevent="doSearch">Search</button>
      </div>

``js methods: { doSearch () { console.log('doSearch') this.$router.push(/search/0?s=${encodeURIComponent(this.q)}`)
}
}
}

`SearchPage`
```js
    validate ({ store, params }) {
      console.log('validate')
      return true
    },

    fetch ({ store, params, error, query }) {
      console.log('fetch')

      return store.dispatch(action, { search: query.s })
        .catch(function (reason) {
          error({statusCode: 500, message: reason})
        })

    },

When I do first search everything is ok. I get on console:

validate
fetch

But when I do Search again (change search text and hit enter) I only get:

validate

After research I think this is the same problem as:
https://github.com/nuxt/nuxt.js/issues/2519

But I did't find the solution yet.

This question is available on Nuxt.js community (#c2277)

Most helpful comment

FIX!

I added to the page

export default {
    watchQuery: ['s'],
    [...]
}

and it started to work again! 馃憤

All 2 comments

FIX!

I added to the page

export default {
    watchQuery: ['s'],
    [...]
}

and it started to work again! 馃憤

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VincentLoy picture VincentLoy  路  3Comments

pehbehbeh picture pehbehbeh  路  3Comments

msudgh picture msudgh  路  3Comments

jaredreich picture jaredreich  路  3Comments

shyamchandranmec picture shyamchandranmec  路  3Comments