Skip to main content

getProjects()

Description

Gets a promise with an array of projects objects

info

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

Usage

getProjects(): Promise<obj[]>;

Response

The getProjects() method sends a request to the server by the GET method and returns a promise with data on projects.

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