Write REST API with Composite Entities in Express and Test using Postman - Lab Task 7
This is simple task. You have already looked at how to develop a REST API in lecture. We used 'product' entity as an example. In this task you are supposed to extend the lecture code by adding following stuff into API or endpoint:
- Create API for an object that has multiple attributes e.g. use student with id, name, gender, email, address, phone_numbers. Create multiple endpoints for different operations e.g. CRUD (Create, Retrieve, Update and Delete) and list multiple records.
- Add 'address' as field in the 'student' object. The 'address' shall be an object in itself with street_address, city and country as fields. It would make the 'student' object composite ... means, an object that has-a object.
- The 'phone_numbers' field should be an array of string i.e. you shall allow user to manage multiple numbers.
- It would help you to undertand how we can create and consume JSON for composite objects. In real applications, most of objects are composite in nature.
Comments
Post a Comment