Question: The objective of this task is to write an API with one GET endpoint. Requirements You are required to write an API with Express that
The objective of this task is to write an API with one GET endpoint.
Requirements
You are required to write an API with Express that will contain the following endpoint:
GET users
endpoint should return status code on successful request;
endpoint should return the data taken from the mockedup database using the provided helper function getUsers. This function returns an array of user objects containing id number name string and role string An example array might appear as follows:
id:
"name": "John",
"role": "admin"
id:
"name" : "Juan",
"role": "developer"
endpoint should accept a query parameter name which will contain a string;
when parameter name is provided, all users whose name property is equal to the name query parameter must be returned it may happen that there will be more than one match If no users with the given name are found, an empty array must be returned.
Hints
Your solution will be evaluated based on its correctness; performance and coding style will not be assessed.
You can assume that the d name and role properties of the users returned from the database are present and of the correct types. You do not have to verify them.
You do not have to take care of unsuccessful requests; the response is always successful and the status code must equal
Available packageslibraries
Express:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
