I did get request from angular to nodejs but I have an error 304 from nodejs and from angular I have a status 200 and error:

"SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse"

ANGULAR

    import { Component, OnInit } from '@angular/core';
    import { HttpClient, HttpHeaders } from '@angular/common/http'



    @Component({
    selector: 'app-main',
    templateUrl: './main.component.html',
    styleUrls: ['./main.component.css']
    })
    export class MainComponent implements OnInit {

    url:string="/api"; // it's from a proxyconfig.json        

    constructor(private http: HttpClient) { }

    ngOnInit() {
      this.connecte()
    }

    connecte(){
    let headers = new HttpHeaders().set('Content-type', 'application/json; 
    charset=utf-8');
    this.http.get<any[]>(this.url, 
    {headers,responseType:"json"}).subscribe(data =>console.log(data) )
      }



    }

NODEJS

    router.get('/', function(req, res) {
       var moi="salut"
       var salut=JSON.stringify(moi)
       res.json(salut)
    });

0 Answers