2016-10-04 51 views
0

这是我使用这个服务类如下角JS2 HTTP GET错误

@Injectable() 
export class LoginService{ 
    baseUrl:string; 
    token:string; 
    constructor(private _http: Http, private _loggerService: LoggerService) { 
     this.baseUrl = "http://localhost:49454"; 
     this.token = ''; 
    } 

    private extractData(res: Response) { 
     let body = res.json(); 
     console.log('-------------------------------------------') 
     console.log(body); 
     console.log('-------------------------------------------') 
     return body.data || { }; 
    } 

    private handleError (error: any) { 

     console.log('-------------------------------------------') 
     console.log('XXX'); 
     console.log('-------------------------------------------') 
     let errMsg = (error.message) ? error.message : 
      error.status ? `${error.status} - ${error.statusText}` : 'Server error'; 
     console.error(errMsg); 
     return Observable.throw(errMsg); 
    } 

    public pingpong() { 

     var test = 'http://localhost:33345/Apple/Bear'; 

     var sd = this._http.get(test) 
      .map(this.extractData) 
      .catch(this.handleError); 



     return sd; 

    } 

} 

庵调用乒乓球()从TS方法来发送GET请求得到

Exception: TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context 

庵错误组件

为什么我在这个特定的类中得到上述错误?

回答

0

发生这种情况是因为我没有订阅请求,因为它是可观察的并且在此之前尝试访问它。