@rajbasilio wrote:
This is my provider file from ionic
getJobDetails() { if(this.data) { return Promise.resolve(this.data); } return new Promise(resolve =>{ let headers = new Headers(); headers.append('Content-Type','application/json'); this.http.get('http://localhost:3000/api/jobdetail',{headers: headers}) .map(res => res.json()) .subscribe(data => { this.data = data; resolve(this.data); }); }); }below is the code where I’m trying to print the data in console log
constructor(public jobdetail: JobsDataProvider) ionViewDidLoad() { this.jobdetail.getJobDetails().then((data) => { console.log(data); this.jdetails = data; }); }why I’m getting the error as after passing the headers.
Failed to load http://localhost:3000/api/jobdetail: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8100’ is therefore not allowed access. Response {_body: ProgressEvent, status: 0, ok: false, statusText: “”, headers: Headers, …} headers : Headers {_headers: Map(0), _normalizedNames: Map(0)} ok : false status : 0 statusText : “” type : 3 url : null _body : ProgressEvent {isTrusted: true, lengthComputable: false, loaded: 0, total: 0, type: “error”, …} proto : Body
Posts: 1
Participants: 1