$20
Learning Outcomes:
- Work with the Back-End framework/library of your choice (i.e., the one you have decided to use for your project).
- Understand how API calls are written in the Back-End framework/library you have chosen (i.e., Express.js or Flask).
- Work individually to create a simple API.
Instructions:
- Use the code shown in the tutorial video for GET API, the API returns a list of user objects, and add new methods for a POST, PUT and a new GET API request.
GET : <your_application_link/users
Sample Success Response :
{
message : “Users retrieved”, success : true, users : [{ email : “abc@abc.ca”, firstName : “ABC”, id : “5abf6783”
}, {
email : “xyz@xyz.ca”, firstName: “XYZ”,
id : “5abf674563”
}]
}
- The PUT API should be able to update email and/or firstname of an existing object in the list. The new email and firstname should be passed in the body of the request.
PUT - <your_application_link/update/:id body data:
{ email : “xyz@xyz.ca”, firstName: “XYZ”,
}
Sample Success Response :
{
message : “User updated”, success : true
}
- The POST API should add a New User Object to the list and generate an ID for the user. The object details should be passed in the body of the request.
POST - <your_application_link/add body data:
{ email : “xyz@xyz.ca”, firstName: “XYZ”,
}
Sample Success Response:
{
message : “User added”, success : true
}
- Finally, a new GET API should be written, which should return a single user object given its username.
The username can be passed as a query or path parameter.
GET- <your_application_link/user/:id
Sample Success Response :
{
success : true, user : {
email : “xyz@xyz.ca”, firstName: “XYZ”,
id : “5abf674563”
}
}
- No front-end is required for this tutorial.
- Consider failure responses for each request as well (e.g., 404, 400, 500 responses and appropriate json messages).