I have a requirement to pull a few resources from another domain that belongs to my company. I want to get protected HTML content using GET requests.
When the user exits the application, the requested content will return 302 to the login page.
My attempts to sniff the headlines for 302 did not return what I had hoped so far. The response returned by my Observable is 200 (login page).
Here is my sample application.
export class MenuComponent implements OnInit { private _resourceUrl = "http://localhost:3001/resources/menu"; constructor(private _http: Http){ } menu: string; ngOnInit(): void { this.getMenu() .subscribe( response => { console.log(`Response status: ${response.status}`); this.menu = response.text(); }, error => console.log(<any>error)); } getMenu(): Observable<Response>{ return this._http.get(this._resourceUrl) .map((response: Response) => response) .catch(this.handleError); } private handleError(error: Response){ console.log(error); return Observable.throw(error.json().error || 'Server Error'); } }
Am I even on the right track?
source share