I am trying to find a way to eliminate unnecessary slashes from the URL when using history.pushState
to include query parameters in Vue.js
This is my Vue.js method:
export default {
name: "Home",
metaInfo: {
title: "صفحه اصلی"
},
data() {
return {
files: {}
}
},
methods: {
type(file) {
if (file.membership && file.price)
return `${file.membership.name},نقدی`
if (file.price)
return "نقدی";
if (file.membership)
return file.membership.name
},
getFiles(page=1){
let queries=this.$route.query;
queries.page=page
axios.get(`/api/files`,{
params:queries
})
.then(({data}) => {
this.files = data;
window.history.pushState(null,'home',"?"+data.meta.queries) // queries add in this line
})
}
},
created() {
this.getFiles(this.$route.query.page)
}
}
The URL after adding queries:
http://localhost:8000/?page=1
I would like to remove the slash so that it looks like http://localhost:8000?page=1