Refactoring our Frontend
The create API call for our frontend will slightly change the interface, enabling the sending of the ID when updating the to-do item from pending to done. This means altering the ToDoItem
interface, and providing a NewToDoItem
interface with the following code:
// ingress/frontend/src/interfaces/toDoItems.ts
export interface NewToDoItem {
title: string;
status: TaskStatus;
}
export interface ToDoItem {
id: number;
title: string;
status: TaskStatus;
}
This means that our create API call now takes the following form:
// ingress/frontend/src/api/create.ts
import { NewToDoItem, ToDoItems, TaskStatus }
from "../interfaces/toDoItems";
import { postCall } from "./utils";
import { Url } from "./url";
export async function createToDoItemCall(title: string) {
const toDoItem: NewToDoItem = {
title: title,
status: TaskStatus.PENDING
};
return postCall<NewToDoItem, ToDoItems>(
new...