1 回答
TA贡献1859条经验 获得超6个赞
像这样进行更改:
func indexHandler(w http.ResponseWriter, req *http.Request) {
setupResponse(&w, req)
if (*req).Method == "POST" {
fmt.Println(req.Header)
fmt.Println(req.ParseForm())
fmt.Println(json.NewDecoder(req.Body))
}
}
角度客户端
login(username: string, password: string) {
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json charset=utf-8'})
};
return this.http.post(`${environment.APIEndpoint}/signin`, `{"username":username, "password":password}`, httpOptions).pipe(map(user => {
// login successful if there's a jwt token in the response
if (user && user) {
// store user details and jwt token in local storage to keep user logged in between page refreshes
localStorage.setItem('currentUser', JSON.stringify(user));
}
return user;
}));
}
- 1 回答
- 0 关注
- 102 浏览
添加回答
举报