-1
I’m using vue.js
with axios
to make Cruds but I have a question about routes.
I have the following routes:
| DELETE | admin/deleteprod/{id} | componet_3.produtos | App\Http\Controllers\ProdutoController@destroy
| PUT | admin/updateprod/{id} | componet_2.produtos | App\Http\Controllers\ProdutoController@update
I’m using the following methods:
updat:function(id){
var url='updateprod/'+ id;
axios.put(url, this.fillproduto).then(response=>{
this.getProdutos();
this.fillproduto={'id':'','nome_pro':'','descricao_pro':'' };
$('#edit').modal('toggle');
});
console.log(url);
},
deleteprod:function(id){
var url='deleteprod/'+ id;
axios.delete(url).then(response=>{
this.getProdutos();
});
//alert('id');
console.log(url);
} ,
As you can see, I’m not using the url in the methods only the last parameter, because if I use the url whole, the method stops working.
My question is whether this is normal and can generate any future problems in my application. I haven’t found any documentation about this.
Yes. You may have problems. If you have at the beginning page (
/
), the request will be made tohttps://www.example.com/updateprod/<id>
, but if you have in a sub-page (/category/t-shirt
), the request will be made tohttps://www.example.com/category/t-shirt/updateprod/<id>
. P.S.: Unless you set the optionbaseURL
– Valdeir Psr