Created
November 2, 2018 10:48
-
-
Save LayZeeDK/414a2091484ac53662d682e7f4d3f145 to your computer and use it in GitHub Desktop.
TypeScript: Todo item with constructor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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