Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obj is undefined error showing on login subscribe #21

Closed
iruthaya opened this issue Dec 20, 2017 · 2 comments
Closed

obj is undefined error showing on login subscribe #21

iruthaya opened this issue Dec 20, 2017 · 2 comments

Comments

@iruthaya
Copy link

I am using the Rocket.Chat.RealTime.API.RxJS to integrating with my existing ionic (3.7) mobile application. my application requirement is Rocket.chat direct message only.

Server Setup Information:

Version of Rocket.Chat Server: 0.59.1
Operating System: Ubuntu 14.04.5 LTS
Deployment Method: Docker

My sample Code


import { Component } from '@angular/core';
import { IonicPage, LoadingController, ToastController, MenuController, Platform } from 'ionic-angular';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { LoginServices } from '../../services/loginservices';
import { Storage } from '@ionic/storage';
import { Events } from 'ionic-angular';
import { Network } from '@ionic-native/network';
import { RealTimeAPI } from "rocket.chat.realtime.api.rxjs";


@IonicPage()
@Component({
  selector: 'page-login',
  templateUrl: 'login.html',
})
export class LoginPage {

  loginData = { UserName: '', Password: '', RememberMe: false };
  data: any;
  loginForm: FormGroup;
  isConnectionExists: boolean = true;
  constructor(public authService: LoginServices, public loadingCtrl: LoadingController, private toastCtrl: ToastController, public fb: FormBuilder, public menuCtrl: MenuController, public storage: Storage, public events: Events, public platform: Platform, public network: Network) {
  
  }
 
  doLogin() {

    if (this.loginForm.dirty && this.loginForm.valid) {
     
        this.showLoader();
        
        const realTimeAPI =  new RealTimeAPI("ws://mydomain:3001/websocket");
        realTimeAPI.keepAlive(); 
        const auth = realTimeAPI.login(loginData.UserName, loginData.Password);
        auth.subscribe(
          (data) => console.log(data),
          (err) => console.log(err),
          () => console.log('completed'));
       
    }
  }

}

Screenshot of my console

image

Please any one help me on this.

@iruthaya iruthaya changed the title obj is undefined response showing on login subscribe obj is undefined error showing on login subscribe Dec 20, 2017
@inf3cti0n95
Copy link
Owner

@iruthaya The Screenshot is hard to read, can you Copy the Log and post it.

@iruthaya
Copy link
Author

iruthaya commented Jan 2, 2018

i'm forget to call realTimeAPI.connectToServer() before calling realTimeAPI.keepAlive().
After adding this function it's working perfect..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants