My component
saveStudentDetails(values) {
const studentData = {};
studentData['s_pNumber'] = values.s_pNumber;
studentData['s_address'] = values.s_address;
studentData['s_pCode'] = values.s_pCode;
studentData['s_city'] = values.s_city;
studentData['s_state'] = values.s_state;
studentData['s_country'] = values.s_country;
this.crudService.createAddress(studentData).subscribe(result => {
this.student = result;
this.toastr.success('Your data has been inserted', 'Success !', { positionClass: 'toast-bottom-right' });
this.router.navigate(['/finance']);
},
err => {
console.log('status code ->' + err.status);
this.toastr.error('Please try again', 'Error !', { positionClass: 'toast-bottom-right' });
});}
My Service
createAddress(data) {
const postHttpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
})
};
postHttpOptions['observe'] = 'response';
return this.http.put(this.url + 'address/${id}', data, postHttpOptions)
.pipe(map(response => {
return response;
}));
}
Why does my service did not send any data to my back-end, when i press a button to update it does not show any error. I just return true and navigate to finance page instead of showing any error. But in my database, the data is not updated. But when i tested my back-end using postman, it is working. Does not have any error.