app.component.ts:
import { Component } from '@angular/core';
import { Http, Response } from '@angular/http';
import 'rxjs/add/operator/map';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app will work!!';
private apiUrl = 'https://address-book-demo.herokuapp.com/api/contacts';
data: any = {};
constructor(private http: Http){
console.log('hellooooooo');
this.getContacts();
this.getData();
}
getData(){
return this.http.get(this.apiUrl)
.map((res: Response) => res.json())
}
getContacts(){
this.getData().subscribe(data => {
console.log(data);
this.data = data;
})
}
}
I am trying hit the above apiurl and get the data in my console.it is working fine. But, When i change the url as "https://www.getpostman.com/collections/010e61af1......." then i am not able to hit that. (it is giving cross origin issue).
Once, i install CORS plugin it is working fine.
How, can i do that without CORS plugin.
and i am very new to work with postman api.