Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to use the HTTP method for creating a new resource.
Node.js
app.[1]('/items', (req, res) => { res.send('Create item'); });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET instead of POST
Using DELETE to create resources
✗ Incorrect
The POST method is used to create new resources on the server.
2fill in blank
mediumComplete the code to use the HTTP method for reading a resource.
Node.js
app.[1]('/items/:id', (req, res) => { res.send('Read item'); });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST to read data
Using DELETE to read data
✗ Incorrect
The GET method is used to read or retrieve data from the server.
3fill in blank
hardFix the error in the code by choosing the correct HTTP method for updating a resource.
Node.js
app.[1]('/items/:id', (req, res) => { res.send('Update item'); });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST to update
Using GET to update
✗ Incorrect
The PUT method is used to update an existing resource completely.
4fill in blank
hardFill both blanks to handle partial updates and deletions of a resource.
Node.js
app.[1]('/items/:id', (req, res) => { res.send('Partial update'); }); app.[2]('/items/:id', (req, res) => { res.send('Delete item'); });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using PUT for partial updates
Using POST for deletion
✗ Incorrect
PATCH is used for partial updates, and DELETE is used to remove resources.
5fill in blank
hardFill all three blanks to complete the CRUD operations with correct HTTP methods.
Node.js
app.[1]('/items', (req, res) => { res.send('Create item'); }); app.[2]('/items/:id', (req, res) => { res.send('Read item'); }); app.[3]('/items/:id', (req, res) => { res.send('Delete item'); });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing GET and POST
Using PUT for deletion
✗ Incorrect
POST creates, GET reads, and DELETE removes resources in REST APIs.