调用post请求但是获取请求调用network angular 5

时间:2018-03-30 16:41:34

标签: angular

尝试发帖请求,但是它正在调用get方法,请帮帮我

server.service.ts文件

export class ServerService {
    constructor(private http: HttpClient, private cookieService: CookieService) { }

    postData(url, payload) {
        debugger
        const headers = new HttpHeaders(
            { 'Authorization': this.cookieService.get('token') }
        );
        let apiURL = 'http://192.168.100.4:8000' + url;
        let api = null;
        return this.http.post(apiURL, payload,
            { headers: headers });
    }
}

otp.component.ts

otpPost(){
      var self = this;
      let otpURL = '/verifyotp';
      let payload = {"otp": self.signUpForm.controls.otp.value};
      self.serverService.postData(otpURL, payload)
        .subscribe(
          (data) => {
            console.log(data);
          },
          (err) => console.log(err)
        )
    }

网络电话enter image description here

邮差应用响应 enter image description here

集管 enter image description here

1 个答案:

答案 0 :(得分:0)

-11A肯定意味着您正在尝试在不是Status Code: 405 METHOD NOT ALLOWED的现有API端点上发帖。我建议验证端点上提供的HTTP协议。