I am making a mobile app using Ionic and Angular i have a function in my angular service that sends a post request to the server
the problem i have is that request is never sent just nothing happens when i use the request in the URL it works but not in my app
marquerDevoirLu(devoir_id){
console.log(devoir_id);
let etudiant_id = this.loginService.importantdata['etudiant_id'];
console.log(etudiant_id);
let utilisateur_id = this.loginService.importantdata['utilisateur_id'];
console.log(utilisateur_id);
console.log(`${this.baseUrl}?func=marquerDevoirLu`)
return this.http.post(`${this.baseUrl}?func=marquerDevoirLu`,{etudiant_id, devoir_id, utilisateur_id}).pipe(map(user => {
console.log(user['result']);
if(user['result'] == 'success'){
console.log('success');
}
else{
console.log('echec');
}
}));
}
CodePudding user response:
Please check if you make a subscription, if you do map function is returning a value so return something. If you only want to use the data to log, use tap or move the function to the subscription.
return this.http.post(${this.baseUrl}?func=marquerDevoirLu,{etudiant_id, devoir_id, utilisateur_id}).pipe(tap(user) => {user['result']?console.log('success'):console.log('echec')}).subscribe((value)=>{})