前面的打字稿代码是:
signIn(signInCredential: SignInCredential): Promise<any> {
//Build the form package
let queryParam:string = 'principal=' + encodeURIComponent(signInCredential.principal) +
'&password=' + encodeURIComponent(signInCredential.password);
//Trigger Http
return this.http.post(signInUrl, queryParam, { headers: this.formHeaders })
.toPromise()
.then(() => null)
.catch(error => this.handleError(error));
}
后端golang代码是:
func (cc *CommonController) Login() []byte {
group := ColorGroup{
ID: 1,
Name: "Reds",
Colors: []string{"Crimson", "Red", "Ruby", "Maroon"},
}
data, err := json.Marshal(group)
if err != nil {
fmt.Println("error:", err)
}
return data
}
角度路由器是:
beego.Router("/login", &controllers.CommonController{}, "post:Login")
如何在typescipt的http.post中获取Login()返回的数据?
感谢所有回复!