這是我的控制臺:GET http://localhost:8080/api/photos.json?token=ABCDEFGHIJKLMNOPQRSTUVWXYZ200 OK 0 jquery.js (line 8526)|Params| Headers Response JSONtoken ABCDEFGHIJKLMNOPQRSTUVWXYZ我在參數選項卡中。我如何訪問它,例如將令牌登錄到我的終端窗口。在節點: request.param('token')
2 回答

慕工程0101907
TA貢獻1887條經驗 獲得超5個贊
我想你有一個http.Request. 假設它被稱為hr。
然后你可以做
hr.ParseForm()
之后你可以使用hr.Formwhich 定義如下:
// Form contains the parsed form data, including both the URL
// field's query parameters and the POST or PUT form data.
// This field is only available after ParseForm is called.
// The HTTP client ignores Form and uses Body instead.
Form url.Values
url.Values地圖在哪里:
type Values map[string][]string
這是使用解析形式的示例,其中我只對給定 name 的第一個值感興趣:
func getFormValue(hr *http.Request, name string) string {
if values := hr.Form[name]; len(values) > 0 {
return values[0]
}
return ""
}
- 2 回答
- 0 關注
- 307 瀏覽
添加回答
舉報
0/150
提交
取消