Fetching data


i have a problem here.can anyone help me?

this is my error:
SyntaxError: Unexpected token N in JSON at position 0
at JSON.parse ()
at Response.Body.json (body.js:22)
at MapSubscriber.project (bethdata.ts:19)
at MapSubscriber._next (map.js:77)
at MapSubscriber.Subscriber.next (Subscriber.js:89)
at XMLHttpRequest.onLoad (xhr_backend.js:72)
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (ng_zone.js:227)
at t.invokeTask (polyfills.js:3)
at e.runTask (polyfills.js:3)
(anonymous) @ home.ts:37
SafeSubscriber.__tryOrUnsub @ Subscriber.js:223
SafeSubscriber.error @ Subscriber.js:184
Subscriber._error @ Subscriber.js:128
Subscriber.error @ Subscriber.js:102
MapSubscriber._next @ map.js:80
Subscriber.next @ Subscriber.js:89
onLoad @ xhr_backend.js:72
t.invokeTask @ polyfills.js:3
onInvokeTask @ ng_zone.js:227
t.invokeTask @ polyfills.js:3
e.runTask @ polyfills.js:3
invoke @ polyfills.js:3

this is my provider:
import { Injectable } from ‘@angular/core’;
import { Http } from ‘@angular/http’;
import ‘rxjs/add/operator/map’;

Generated class for the Bethdata provider.

See https://angular.io/docs/ts/latest/guide/dependency-injection.html
for more info on providers and Angular 2 DI.
export class Bethdata {

constructor(public http: Http) {
console.log(‘Hello Bethdata Provider’);

   return this.http.get('http://bethlehembulletin.comlu.com/emp.php').map(res => res.json())



and my home.ts:
import { Component } from ‘@angular/core’;
import { NavController } from ‘ionic-angular’;
import { Bethdata } from ‘…/…/providers/bethdata’;

selector: ‘page-home’,
templateUrl: ‘home.html’,
providers: [Bethdata]
export class HomePage {

constructor(public navCtrl: NavController, public bethservice: Bethdata) {

    this.bethservice.getRemoteData().subscribe(result => {
    err =>{
        () => console.log('getdata completed')


tnx in advance guys.


Your API is returning non JSON results:

Nice Work!!{'success':true, 'data':[{"emp_id":"1","emp_name":"tet","emp_salary":"900,000"},{"emp_id":"2","emp_name":"jemai","emp_salary":"800,00"}]}	

you should change your PHP to return pure JSON. Remove the “Nice Work!!” and the Hosting24 analytics code. Use this site to validate your JSON: http://jsonlint.com


bro, tnx so much for helping.it works for me. :slight_smile: