0

I'm trying to get data from my local database. local url: http://localhost:8000/

I call this in my service /getPersonalInfoData status showing 200, but I can't see any data there.

component.ts:

var data = this.personalInfoService.getPersonalInfoData()
            .subscribe(arg => this.driverData = arg);
            console.log(data);

personalInfoService:

return this.http.get('/getPersonalInfoData').map((res: Response) => { console.log(res); return res; });

backend data source API(Nodejs):

routes.get('/getPersonalInfoData',personal_info_controller.getPersonalInfoData);
2
  • have you tested your api using postman ? Commented Jan 29, 2018 at 9:53
  • ya,...its working fine Commented Jan 29, 2018 at 11:57

1 Answer 1

1

In personalInfoService:-

1.import { Http, Response, Headers, RequestOptions, URLSearchParams} from'@angular/http';

2.In method add this code:

const headers = new Headers({
      'Content-Type': 'application/json',
      'Cache-control': 'no-cache',
      Expires: '0',
      Pragma: 'no-cache'
    });
    const options = new RequestOptions({ headers: headers });
    return this.http.get(Url, options).map(res => {
      return res.json();
    });

Hope this will help you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.