I am calling my get rest service like this,
makeGetCall(url: string): Observable<any> {
const headers = new Headers({'auth-code': 'auth-code',
'from':'app'});
return this.http.get(AdminConstants.BASE_URL + this.SEPARATOR + url,{
headers: headers
})
.map(this.extractData)
.catch(this.handleErrorObservable);
}
private extractData(res: Response) {
console.log('extract data');
console.log(res);
const body = res.json();
return body || {};
}
private handleErrorObservable(error: Response | any) {
console.log('error in service');
console.log(error.message);
return Observable.throw(error.message || error);
}
and My rest service is:
console.log('inside get all user');
ApiUser.find().then(users => {
console.log('length : '+users.length)
res.status(200).send(users);
}, error => {
res.send(500).send(error);
})
I am using MEAN stack for my application.
Here is my problem, when I am calling my rest service from postman its working.Even in the chrome/mozilla console I can see my response as expected.response header
But from my angular 2 application my handleErrorObservable method is called and that too with an error without proper message.
I just installed ssl certificates on my server, before ssl this was working inside my application. Also to add post requests are working.
I don't know what I am missing. Please help. Thanks in advance.