I am trying to send a post http request to change the content of my file but when I do the post request, the log says error 404 the file does not exist. (http get worked on the same url). I have no idea why it does that, can someone help me?
bd.service.ts
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': 'my-auth-token'
})
};
postData(filename:string, data:any[]){
return this.http.post(filename,JSON.stringify(data),httpOptions);
recherche.component.ts
toggle(cpr:string){
this.bdService.lstLivres=this.livres;
this.bdService.togglePanier(cpr);
this.bdService.postData('http://localhost:4200/assets/data/panier.json',
this.bdService.getPanier()).subscribe(r=>console.log(r));
);
}
http://localhost:4200/assets/data/panier.json
[{
"id":1,
"cpr":1,
"aut":"Denis martin" ,
"tit": "Manger a tout les jours",
"pri": 75,
"rab": 0.10,
"des": "Comment lire à tout les jours et ne pas arrêter",
"nic": "Secondaire",
"img": "../assets/images/image2.jpg"
},
{
"id":2,
"cpr":2,
"aut":"Denis martin" ,
"tit": "Lire à tout les jours",
"pri": 50,
"rab": 0.10,
"des": "Comment lire à tout les jours et ne pas arrêter",
"nic": "Secondaire",
"img": "../../assets/images/image2.jpg"
},
{
"id":3,
"cpr":3,
"aut":"Denis martin" ,
"tit": "Lire à tout les jours",
"pri": 50,
"rab": 0.10,
"des": "Comment lire à tout les jours et ne pas arrêter",
"nic": "Secondaire",
"img": "../../assets/images/image2.jpg"
}
]