Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2 - Cannot set property 'stack' of undefined [closed]

I have issue with angular2, when I had created service, and attached it into appModule to providers:[] section, I had error:

Uncaught TypeError: Cannot set property 'stack' of undefined
    at SyntaxError.set [as stack] (eval at <anonymous> (http://localhost:8080/vendor.js:94:2), <anonymous>:1628:63)
    at assignAll (eval at <anonymous> (http://localhost:8080/polyfills.js:2217:2), <anonymous>:704:29)

I have done two apps and I havent meet with similar error before... This is my simple service file:

Injectable()
export class RecordService {

    private API_END_POINT: string = 'app/records';
    private API = process.env.API_END_POINT;

    constructor(private http: Http ) {

    }

    getRecords(): Observable<any> {
        return this.http
            .get( this.API_END_POINT )
            .map( (res:Response) => res.json().data as RecordModel )
            .catch(this.handleError);

    }

    private handleError(error: any): Promise<any> {
        console.error('An error occurred', error);
        return Promise.reject(error.message || error);
    }

}

I have no idea how to fix that, there is no any information about this err nowhere... Please for help!

like image 260
Uland Nimblehoof Avatar asked Jan 13 '17 11:01

Uland Nimblehoof


1 Answers

there seems to be a bug in zone.js. Try fixing the version to 0.7.4 and see if the error message is more explicit

check here for more info

npm install --save [email protected]

like image 97
Aleksandar Terziev Avatar answered Oct 21 '22 05:10

Aleksandar Terziev