The fronted typescript code is:
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));
}
The backend golang code is:
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
}
The angular router is:
beego.Router("/login", &controllers.CommonController{}, "post:Login")
How can I get the data returned by the Login() in the http.post of typescipt?
Thanks for all reply!