Angular没有向后端发送PUT请求

时间:2019-03-16 05:20:18

标签: angular angular7

我的组件

 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' });
});}

我的服务

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;
  }));
}

为什么我的服务没有向我的后端发送任何数据,当我按下一个按钮进行更新时,它没有显示任何错误。我只返回true并导航到财务页面,而不显示任何错误。但是在我的数据库中,数据没有更新。但是,当我使用邮递员测试我的后端时,它正在工作。没有任何错误。

0 个答案:

没有答案