Winkel 2 SyntaxError: Unexpected token < im JSON-an der position 0 zu JSON.parse (<anonym>)

Ich bin dem Aufruf der web-API aus meiner Angular2 Komponente service in Visual Studio, aber ständig erhalte ich die Fehlermeldung "Unerwartetes token < im JSON-an der position 0 zu JSON.parse ()".

ComponentService:

       import { Injectable } from '@angular/core';
       import {Http, Response } from '@angular/http';
       import { IData } from '../Common/details';
       import { Observable } from 'rxjs/Observable';
       import 'rxjs/add/operator/map';

       @Injectable()  
       export class AniversaryService {
         constructor(private _http:Http) { }
         getImages(): Observable<IData[]> {
                return this._http.get("/api/ImageService/Details")
                .map((response: Response) => <IData[]>response.json()      
                };
        }

und entsprechenden Komponente:

    import { Component, OnInit } from '@angular/core';
    import { DomSanitizer } from '@angular/platform-browser';
    import { IData } from '../Common/details';
    import { AniversaryService } from './Aniversary.service';

    @Component({
    selector: 'my-AniversaryComponent',
    providers: [AniversaryService]
    })

    export class AniversaryComponent implements OnInit {
       data: IData[];
       constructor(private _aniversaryservice: AniversaryService) { }
       ngOnInit() {
       this._aniversaryservice.getImages().subscribe((details) => this.data 
       =details); 
       }
     }

    }

Diese sind die Bilder der Netzwerk-Kopf-und meine Antwort (Antwort ist in Javascript):

Winkel 2 SyntaxError: Unexpected token < im JSON-an der position 0 zu JSON.parse (<anonym>)

Winkel 2 SyntaxError: Unexpected token < im JSON-an der position 0 zu JSON.parse (<anonym>)

Manchmal mein status code zeigt 200 ok und content-Typ (in der Antwort-Header): application/javascript

Bitte helfen Sie mir dieses problem zu lösen.

Danke für die Hilfe im Voraus

InformationsquelleAutor Bhargav | 2017-11-08
Schreibe einen Kommentar