文章詳情頁
angular.js - angular4 發出post請求 服務端顯示OPTIONS
瀏覽:251日期:2024-09-14 10:17:57
問題描述
private headers = new Headers({’Content-Type’: ’application/json’});
private url = ’localhost:3000/users/register’; constructor(private http: Http) { }registerEmail(link:string , email: string , password: string): Promise<any> {return this.http .post(this.url, JSON.stringify({email: email , password: password}), {headers: this.headers}) .toPromise() .then(res => res.json().data) .catch(this.handleError);}
用postman請求正常顯示post請求
問題解答
回答1:你運行POST請求的主機是什么?angular在跨域請求的時候會有一個Options,好像是檢查是否允許跨域的。我目前的項目里前后端域名不一樣的,也是Options和Request同時出現,以前同域名的時候沒有。
相關文章:
1. javascript - 有適合開發手機端Html5網頁小游戲的前端框架嗎?2. Python中使用超長的List導致內存占用過大3. javascript - JS變量被清空4. javascript - 關于apply()與call()的問題5. javascript - jQuery post()方法,里面的請求串可以轉換為GBK編碼么?可以的話怎樣轉換?6. 安全性測試 - nodejs中如何防mySQL注入7. java - 在用戶不登錄的情況下,用戶如何添加保存到購物車?8. css3 - 純css實現點擊特效9. javascript - main head .intro-text{width:40%} main head{display:flex}為何無效?10. javascript - axios請求回來的數據組件無法進行綁定渲染
排行榜
