尝试发帖请求,但是它正在调用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)
)
}
答案 0 :(得分:0)
-11A
肯定意味着您正在尝试在不是Status Code: 405 METHOD NOT ALLOWED
的现有API端点上发帖。我建议验证端点上提供的HTTP协议。