[英]Send Post request with parameters in URL
注冊后,我會推送用戶以驗證其帳戶。 我將驗證碼發送到他的電子郵件,他將其添加到輸入中,並通過post API調用發送該值。 我的問題是,當我發出請求時,得到的響應是203非權威信息。 但是當我嘗試使用PostMan進行此過程時,效果很好
我的配套代碼:
verfiy(){
this.code = this.userverfiycode.verfiCode;
this.authService.postData('Verify?userId='+this.user +'&vCode='+ this.code ).then((result) => {
this.responseData = result;
console.log(this.responseData);
console.log(this.user);
console.log(this.code);
console.log(this.type);
if (this.responseData = true) {
this.pushpage()
}
else{
console.log("");
}
}, (err) => {
// Error log
});
}
我的提供者代碼:
let apiUrl = 'http://localhost:50494/api/Account/';
let apiKey = 'sdf4rw-23fs-3454-fsdsd-3we2693243424';
@Injectable()
export class AuthProvider {
constructor(public http : Http) {
console.log('Hello AuthService Provider');
}
UserKey = localStorage.getItem('loginData');
postData( type) {
return new Promise((resolve, reject) => {
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('token', apiKey);
headers.append('api_key', this.UserKey);
this.http.post(apiUrl + type, {headers: headers})
.subscribe(res => {
resolve();
console.log()
}, (err) => {
reject(err);
console.log()
});
});
}
通常, post()的第二個參數是data,第三個參數是{headers};
您可以嘗試發送一些虛擬數據嗎
this.http.post(apiUrl + type, {}, {headers: headers})
.subscribe(res => {});
我想是因為后端沒有獲得您要在post()函數中發送的標頭。
如果Request Headers
正常運行,您能否檢查一下此請求的devtool網絡選項卡
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.