Skip to content

Instantly share code, notes, and snippets.

@LayZeeDK
Created November 2, 2018 10:48
Show Gist options
  • Save LayZeeDK/414a2091484ac53662d682e7f4d3f145 to your computer and use it in GitHub Desktop.
Save LayZeeDK/414a2091484ac53662d682e7f4d3f145 to your computer and use it in GitHub Desktop.
TypeScript: Todo item with constructor
class TodoItem {
id: string;
isDone: boolean;
title: string;
constructor(properties) {
this.id = properties.id;
this.isDone = properties.isDone;
this.title = properties.title;
}
save(): Promise<void> {
return fetch("/todo/" + this.id, {
body: JSON.stringify(this),
method: "POST",
})
.then(() => undefined);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment