Design the Service

The service sits between the controller and the back-end server. The controller functions depend on three functions of the service: get, add, and delete. Let’s design these functions, one at a time. While designing the service, we have to keep in mind the needs of the controller and the expectations of the server. Let’s get started with the get function.

Design the get Function

get should receive two callbacks as parameters and make a GET request to the /tasks endpoint of the server. If the server responded back successfully, the function should call the first callback given to it; otherwise, it should call the second callback.

We don’t have the back end running right now. There’s no need; depending on the real back ...

Get Test-Driving JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.