I'm currently working on a project that is somewhat inspired by this example, but I've encountered a TypeScript error and I would appreciate some guidance on what might be causing it. As far as I can tell, I am following the correct procedures.
Below is part of the code I have written so far:
import {Injectable,Inject} from '@angular/core';
import {Http,Headers,URLSearchParams, Response} from '@angular/http';
import {List, Record} from 'immutable';
import {Observable} from "rxjs/Observable";
const TodoRecord = Record({
id: 0,
description: "",
completed: false
});
export class Todo extends TodoRecord {
id:number;
description:string;
completed: boolean;
constructor(props: any) {
super(props);
}
}
@Injectable()
export class TodoBackendService {
constructor(private http: Http){
this.http = http;
}
getAllTodos(){
return this.http.get("/todo");
}
saveTodo(newTodo: Todo): Observable<List<Todo>> {
var headers = new Headers();
headers.append("Content-Type", "application/json; chartset=utf-8");
return this.http.post("/todo", JSON.stringify(newTodo.toJS()),{headers}).share();
}
}
The line of code in Visual Studio Code that is triggering an error is:
return this.http.post("/todo", JSON.stringify(newTodo.toJS()),{headers}).share();
And here is the error message displayed in VS Code:
https://i.sstatic.net/jQt4A.png
Any assistance or advice on resolving this issue would be greatly appreciated.