Typescript error [Invalid character](ionic 3) while using json post method


#1

am trying to post the data into json file using http post method…
this was my code…
let headers = new Headers();
headers.append(‘Content-Type’, ‘application/json’);
 this.http.post(‘http://localip:8081/logindata’, (data),{headers:headers}) .subscribe(data => {
console.log(data);
});

it reflects with typescript error…


#2

Do you want to share the error or should we guess?


#3

@Gokul15 The character is invalid (to wrap strings with it). Use ' or " instead:

let headers = new Headers();
headers.append('Content-Type', 'application/json');
this.http.post('http://localip:8081/logindata', data, {headers:headers}).subscribe(data => {
	console.log(data);
});