I try to fetch value of the name parameter in URL: http://fakelocalhost:3000/page?name=test
I'm using NuxtJS (v2.11.0) and TypeScript, with nuxt-property-decorator package (v2.5.0).
But, I get an undefined result with console.log(params.name)
.
Here, my full TS code:
<script lang="ts">
import {
Component,
Vue
} from "nuxt-property-decorator";
@Component({
asyncData({ params }) {
console.log(params.name);
}
})
export default class extends Vue {}
</script>
I found the solution...
asyncData({ route }) {
console.log(route.query.name);
}
Use route object instead of params in asyncData method.