Error making a POST request Angular (SyntaxError: Unexpected token in JSON at position 0 at JSON.parse)

1

Angular:

public urlConvenio: string = "http://localhost/teste/sistema/backend/controller/convenio/listar.php";

const httpOptions = {
   headers: new HttpHeaders({
     'Content-Type': 'application/json'
   })
};

//REQUISIÇÃO
public enviaDados() {
    this.http.post(this.urlPost, 
                   JSON.stringify(this.myForm.value), 
                   this.httpOptions).subscribe(res => {
       console.log(res);
    })
 }

Error:

Server:

    
asked by anonymous 08.09.2018 / 00:49

1 answer

0

Add the responseType header in your link

 const httpOptions = {
        headers: new HttpHeaders({ 'Content-Type': 'application/json', 'responseType': 'text' })
    }
    
10.09.2018 / 21:15