gpt4 book ai didi

angular - 调用post请求但在网络 Angular 5上调用get请求

转载 作者:行者123 更新时间:2023-12-02 10:29:30 24 4
gpt4 key购买 nike

尝试执行 post 请求,但它正在调用 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

postman 应用响应 enter image description here

标题 enter image description here

最佳答案

状态代码:405 METHOD NOT ALLOWED 绝对意味着您正在尝试在不是 POST 的现有 API 端点上进行发布。我建议验证端点上提供的 HTTP 协议(protocol)。

关于angular - 调用post请求但在网络 Angular 5上调用get请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49578094/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com