Consuming a RESTful API with the web worker
One of the most common applications of network APIs today in web development is through the implementation of a RESTful API. It is a protocol where each communication is stateless and representative of the type of action required at the destination. The HTTP protocol used on the web provides a perfect match for this type of API, as each network call exposes a method that identifies the type of operation required:
- The
GET
operations retrieve data and files - The
PUT
operations update data - The
POST
operations create new data on the server - The
DELETE
operations erase data on the server
It is easy to see how these methods match CRUD operations, so by making the appropriate network call, the server knows how to process the data received at the proper endpoint. There are many standards used to format the data sent between endpoints. In particular, one of the most common ones is the JSON format, which we so conveniently...