Skip to main content

getProjectTasks()

Description

Gets a promise with an array of tasks objects for the specified project

info

The getProjectTasks() method is a part of the RestDataProvider service intended for working with a server

Usage

getProjectTasks(id: string | number | null): Promise<obj[]>;

Parameters

NameTypeDescription
idstring, number, nullRequired. The ID of the project

Response

The getProjectTasks() method sends a request to the server by the GET method and returns a promise with data on the tasks of the specified project.

Example

const { ToDo, Toolbar, RestDataProvider } = todo;

const activeProject = null;
const url = "http://localhost:3000";
const restProvider = new RestDataProvider(url);

Promise.all([
restProvider.getProjectTasks(activeProject),
restProvider.getProjects(),
]).then(([tasks, projects]) => {
const list = new ToDo("#root", {
tasks,
projects,
activeProject,
});
const toolbar = new Toolbar("#toolbar", {
api: list.api,
});

list.api.setNext(restProvider);
restProvider.setAPI(list.api);
});

Related articles: Working with Server