Question: The code developed for the DELETE method in the lecture does not validate the request pathname against wrong input. In this activity you need to

The code developed for the DELETE method in the lecture does not validate the request
pathname against wrong input. In this activity you need to update the code to account for the
following
Mapping the index arriving from the client-side to the correct index on the server-side.
i.e. if the client sends the following curl request,
curl -X DELETE localhost:8080/1
the first item at index 0 will be deleted rather than the second item at index 1.
Accounting for a missing index. i.e. if the client sends the following curl requests
curl -X DELETE localhost:8080/ or curl -X DELETE localhost:8080
the server replies with
Missing index for item to be deleted
Working with lists that could have indices that are more than one digit number. So far,
the code can handle indices between 0 and 9. Adjust the code to handle indices from 1
to 999.
Accounting for an invalid value for an index. i.e. if the client sends the following curl
request
curl -X DELETE localhost:8080/a
the server replies with
invalid item index
Hint: The JS function Number.isNaN() static method determines whether the passed
value is the number value NaN, and returns false if the input is not of the Number type.
After completing the above modifications, upload the updated todoSrv. js to BB.
The code developed for the DELETE method in the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!