文章詳情頁
angular.js - angular4 發(fā)出post請求 服務(wù)端顯示OPTIONS
瀏覽:181日期: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同時出現(xiàn),以前同域名的時候沒有。
相關(guān)文章:
1. python - 獲取到的數(shù)據(jù)生成新的mysql表2. javascript - js 對中文進行MD5加密和python結(jié)果不一樣。3. mysql里的大表用mycat做水平拆分,是不是要先手動分好,再配置mycat4. window下mysql中文亂碼怎么解決??5. sass - gem install compass 使用淘寶 Ruby 安裝失敗,出現(xiàn) 4046. python - (初學(xué)者)代碼運行不起來,求指導(dǎo),謝謝!7. 為啥不用HBuilder?8. python - flask sqlalchemy signals 無法觸發(fā)9. python的文件讀寫問題?10. 為什么python中實例檢查推薦使用isinstance而不是type?
排行榜

熱門標簽