Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export class LoginRequest {
- username : string;
- password : string;
- }
- export class LoginResponse {
- token : string;
- message : string;
- status : string;
- }
- export class LoginComponent {
- ...
- loginRes : LoginResponse;
- ...
- login(loginReq : LoginRequest) {
- // here how can I get return object
- this.loginRes = this.loginService.login(this.loginReq);
- }
- }
- export class LoginService {
- ...
- loginRes : LoginResponse;
- ...
- login() {
- // here how can I return loginRes object
- this.http.post(API_URL + "weblogin", loginReq)
- .subscribe(
- res => {
- this.loginRes = res.json() as LoginResponse;
- },
- err => {
- this.loginRes = new LoginResponse();
- this.loginRes.message = "Failed to conntect the server";
- this.loginRes.status = "NOT_OK";
- this.loginRes;
- }
- );
- }
- }
Add Comment
Please, Sign In to add comment