$router.push not working with query parameters ... | vue router push not updating query
InmyNuxtJS(v.2.10.2)application,IhaveaURLlikebelowwherepidisapost’sid./post?pid=5e4844e34202d6075e593062ThisURLworksfineandloadsthepostasperthevaluepassedtothepidqueryparameter.However,usercanaddnewpostbyclickingAddPostbuttonontheapplicationbarthatopensadialog.Oncetheuserclicksadd,arequesttoback-endserverismadetosavethepost.Andoncesuccessful,IamtryingtoredirecttheusertothenewpostusingVuerouterpushlikebelow.then(data=>{if(data){this.$router.push({path:`/post?pid=${data.id}`});}})Theproblem...
In my NuxtJS(v. 2.10.2) application, I have a URL like below where pid is a post’s id.
/post?pid=5e4844e34202d6075e593062
This URL works fine and loads the post as per the value passed to the pid query parameter. However, user can add new post by clicking Add Post button on the application bar that opens a dialog. Once the user clicks add, a request to back-end server is made to save the post. And once successful, I am trying to redirect the user to the new post using Vue router push like below
.then(data => { if (data) { this.$router.push({ path: `/post?pid=${data.id}` }); } })The problem is, user is not redirected to the new post, only the query parameter pid in the URL is updated. I have tried different variations of push syntax below. But I am getting the same behavior, redirection does not happen.
this.$router.push({ path: "post", query: { pid: data.id } }); this.$router.push({ name: "post", query: { pid: data.id } });I b...