2
我想知道POST調用如何在Polymer中工作。我知道我必須使用POST調用來發送敏感信息,例如用戶密碼和訪問令牌。我試着這樣做:HTTP POST如何在聚合物中工作?
<iron-ajax
id="AjaxPost"
url="/api/login"
method="POST"
content-type="application/x-www-form-urlencoded"
handle-as="json"
on-response="_handleAjaxPostResponse"
on-error="_handleAjaxPostError"
></iron-ajax>
this.$.AjaxPost.params = { email: "[email protected]", password: "password" };
this.$.AjaxPost.generateRequest();
但是,這將設置在URL中的參數,可以在瀏覽器控制檯等瀏覽:
POST http://localhost:8080/api/login?email=abc%40mgail.com&password=password 400 (Bad Request)
PUT方法允許你設置的數據身體,我認爲這更安全。現在我有兩個問題:
- 我們可以設置POST方法的主體嗎?或者設置參數與設置主體相同?
- 如果可能的話,我應該怎麼提取服務器端的數據?
PS:我們沒有使用SSL的HTTPS連接。話雖如此,可以採用哪種方法來提高安全性?